Example #1
0
        public PacketCommunicator(PacketConnectionBase connection, Stream stream, PacketRegistry registry)
        {
            Registry   = registry;
            Connection = connection;

            Packets       = new BlockingCollection <Packet>();
            Reader        = new BinaryReader(stream, Encoding.UTF8, true);
            Writer        = new BinaryWriter(stream, Encoding.UTF8, true);
            NotifiedTypes = new HashSet <Type>();

            thread(ReadLoop);
            thread(SendLoop);

            void thread(Action act) => new Thread(new ThreadStart(act))
            {
                IsBackground = true
            }.Start();
        }
Example #2
0
 public PacketClient(string ip, int port)
 {
     Ip       = ip;
     Port     = port;
     Registry = new PacketRegistry();
 }
Example #3
0
 public PacketServer(int port)
 {
     Registry        = new PacketRegistry();
     ConnectionsList = new List <PacketServerConnection>();
     Listener        = new TcpListener(IPAddress.Any, port);
 }