Example #1
0
        public NetTcpClient(TcpClient client, StreamProtobuf streamProtobuf)
        {
            Client = client;
            Stream = client.GetStream();

            StreamProtobuf = streamProtobuf;
        }
Example #2
0
        public NetTcpServer(TcpListener tcpListener, StreamProtobuf streamProtobuf)
        {
            TcpListener = tcpListener;
            TcpListener.Start();

            StreamProtobuf = streamProtobuf;

            Clients = new ConcurrentBag <NetTcpClient>();
        }
Example #3
0
 public async Task AcceptPackets()
 {
     await Task.Factory.StartNew(() =>
     {
         while (true)
         {
             if (StreamProtobuf.ReadNext(Stream, out object value))
             {
                 PacketReceivedEvent(this, value);
             }
         }
     }, TaskCreationOptions.LongRunning).ConfigureAwait(false);
 }
Example #4
0
 public void SendToStream <T>(T obj)
 {
     StreamProtobuf.WriteNext(Stream, obj);
 }