示例#1
0
文件: Socket.cs 项目: AlphaBlend/VNet
        protected void SetupSocket()
        {
            socket = new TcpClientWrapper(20);
            socket.ConnectionEstablished += new TcpClientWrapper.ConnectionEstablishedDelegate(socket_ConnectionEstablished);
            socket.ConnectionRefused += new TcpClientWrapper.ConnectionRefusedDelegate(socket_ConnectionRefused);
            socket.Disconnected += new TcpClientWrapper.DisconnectedDelegate(socket_Disconnected);
            socket.DataRead += new TcpClientWrapper.DataReadDelegate(socket_DataRead);

            packet = new Packet();
            packet.DataSent += new Packet.SendDataDelegate(packet_DataSent);
            bufferer = new PacketBufferer(SendDataFinal, null, 100);
        }
示例#2
0
文件: User.cs 项目: AlphaBlend/VNet
            public User(TcpClientWrapper clientSocket, bool isConsole)
            {
                socket = clientSocket;
                _isConsole = isConsole;

                packet = new Packet();
                packet.skipHeaders = isConsole;
                packet.DataSent += new Packet.SendDataDelegate(packet_SendData);
                bufferer = new PacketBufferer(SendDataFinal, null, Config.SendBufferInterval);

                Flags = UserFlags.Normal;
            }
示例#3
0
文件: User.cs 项目: Lynxy/VNet
            public User(TcpClientWrapper clientSocket, bool isConsole)
            {
                socket = clientSocket;
                _isConsole = isConsole;
                packet = new Packet();
                packet.skipHeaders = isConsole;
                packet.DataSent += new Packet.SendDataDelegate(packet_SendData);
                PacketSendBufferer.AddSendHandler(this, SendDataFinal);
                recvBufferer = new PacketBuffer();

                Flags = UserFlags.Normal;
            }
示例#4
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            lock (sockets)
            {
                for (int i = 0; i < 10; i++)
                {
                    TcpClientWrapper sock = new TcpClientWrapper(20);
                    sock.ConnectionEstablished += new TcpClientWrapper.ConnectionEstablishedDelegate(sock_ConnectionEstablished);
                    sock.DataRead += new TcpClientWrapper.DataReadDelegate(sock_DataRead);

                    Packet pack = new Packet();
                    pack.DataSent += new Packet.SendDataDelegate(pack_DataSent);

                    PacketBufferer bufferer = new PacketBufferer(SendDataFinal, sock, 100);

                    sockets.Add(pack, sock);
                    packets.Add(sock, pack);
                    buffers.Add(sock, bufferer);

                    sock.AsyncConnect("127.0.0.1", 4800);
                }
            }
        }
示例#5
0
 void pack_DataSent(Packet packet, ref byte[] data)
 {
     buffers[sockets[packet]].QueuePacket(ref data);
 }
示例#6
0
文件: User.cs 项目: AlphaBlend/VNet
 private void Dispose(bool disposing)
 {
     if (!this.disposed)
     {
         if (disposing)
         {
             socket = null;
             packet = null;
             bufferer = null;
             Channel = null;
         }
         disposed = true;
     }
 }
示例#7
0
文件: User.cs 项目: AlphaBlend/VNet
 protected void packet_SendData(Packet packet, ref byte[] data)
 {
     if (!_canSendData)
         return;
     if (!_isConsole)
         bufferer.QueuePacket(ref data);
 }
示例#8
0
文件: Socket.cs 项目: AlphaBlend/VNet
 protected void packet_DataSent(Packet packet, ref byte[] data)
 {
     bufferer.QueuePacket(ref data);
 }
示例#9
0
文件: User.cs 项目: Lynxy/VNet
 private void Dispose(bool disposing)
 {
     if (!this.disposed)
     {
         if (disposing)
         {
             socket.Client.Dispose();
             socket = null;
             packet = null;
             PacketSendBufferer.RemoveSendHandler(this);
             recvBufferer = null;
             Channel = null;
         }
         disposed = true;
     }
 }