Multiclient is working
This commit is contained in:
parent
aebe4c0f8e
commit
2e4e4c4693
@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
namespace Passer.Control {
|
||||
|
||||
@ -9,6 +10,7 @@ namespace Passer.Control {
|
||||
public UdpClient udpClient;
|
||||
public string ipAddress;
|
||||
public int port;
|
||||
public Stream dataStream;
|
||||
|
||||
public byte networkId = 0;
|
||||
|
||||
@ -48,9 +50,15 @@ namespace Passer.Control {
|
||||
this.udpClient = udpClient;
|
||||
this.ipAddress = null;
|
||||
this.port = port;
|
||||
this.dataStream = new EchoStream();
|
||||
clients.Add(this);
|
||||
}
|
||||
|
||||
public virtual void ProcessMessages() {
|
||||
while (this.messageQueue.TryDequeue(out IMessage msg))
|
||||
ProcessMessage(msg);
|
||||
}
|
||||
|
||||
public void ProcessMessage(IMessage msg) {
|
||||
switch (msg) {
|
||||
case ClientMsg clientMsg:
|
||||
|
@ -1,9 +1,29 @@
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Passer.Control {
|
||||
|
||||
public static class SiteServer {
|
||||
//public static async Task ReceiveData() {
|
||||
// while (true) {
|
||||
// //foreach (var client in Client.clients) {
|
||||
|
||||
// for (int ix = 0; ix < Client.clients.Count; ix++) {
|
||||
// if (ix > 0)
|
||||
// UnityEngine.Debug.Log("Client2 ");
|
||||
// Client client = Client.clients[ix];
|
||||
// if (client == null)
|
||||
// continue;
|
||||
|
||||
// byte packetSize = (byte)client.dataStream.ReadByte();
|
||||
// if (packetSize != 0xFF)
|
||||
// await ReceiveData(client.dataStream, client, packetSize);
|
||||
// // else timeout
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
public static async Task ReceiveData(Stream dataStream, Client client) {
|
||||
while (true) {
|
||||
byte packetSize = (byte)dataStream.ReadByte();
|
||||
|
Loading…
x
Reference in New Issue
Block a user