public NetTcpClient(TcpClient client, StreamProtobuf streamProtobuf) { Client = client; Stream = client.GetStream(); StreamProtobuf = streamProtobuf; }
public NetTcpServer(TcpListener tcpListener, StreamProtobuf streamProtobuf) { TcpListener = tcpListener; TcpListener.Start(); StreamProtobuf = streamProtobuf; Clients = new ConcurrentBag <NetTcpClient>(); }
public async Task AcceptPackets() { await Task.Factory.StartNew(() => { while (true) { if (StreamProtobuf.ReadNext(Stream, out object value)) { PacketReceivedEvent(this, value); } } }, TaskCreationOptions.LongRunning).ConfigureAwait(false); }
public void SendToStream <T>(T obj) { StreamProtobuf.WriteNext(Stream, obj); }