コード例 #1
0
ファイル: Client.cs プロジェクト: TheWicked/OCTGN
 // Indicates if this client is connected
 public Client(IPAddress address, int port)
 {
     // Init fields
     Port = port;
     _address = address;
     _tcp = new TcpClient(address.AddressFamily);
     _handler = new Handler();
     _binHandler = _handler.ReceiveMessage;
     // Create a remote call interface
     Rpc = new BinarySenderStub(_tcp);
 }
コード例 #2
0
 // Indicates if this client is connected
 public Client(IPAddress address, int port)
 {
     // Init fields
     Port        = port;
     _address    = address;
     _tcp        = new TcpClient(address.AddressFamily);
     _handler    = new Handler();
     _binHandler = _handler.ReceiveMessage;
     // Create a remote call interface
     Rpc = new BinarySenderStub(_tcp);
 }
コード例 #3
0
ファイル: Client.cs プロジェクト: YoshiEnVerde/OCTGN
 // Handle an xml packet
 private void XmlReceive(int count)
 {
     // Look for a 0 at the end.
     for (int i = packetPos; i < packetPos + count; i++)
     {
         if (packet[i] == 0)
         {
             // Extract the xml
             string xml = System.Text.Encoding.UTF8.GetString(packet, 0, i);
             // Invoke the handler
             Program.Dispatcher.BeginInvoke(DispatcherPriority.Normal, xmlHandler, xml);
             // Switch to a binary handler if the message asked for it
             if (xml == "<Binary />")
             {
                 binHandler = new BinaryReceiveDelegate(handler.ReceiveMessage);
                 xmlHandler = null;
             }
             // Adjust the packet buffer
             count += packetPos - i - 1; packetPos = 0;
             Array.Copy(packet, i + 1, packet, 0, count);
             i = -1; continue;
         }
     }
     // Adjust the position in the packet buffer
     packetPos += count;
 }
コード例 #4
0
ファイル: Client.cs プロジェクト: 0M3G4/OCTGN
 // Handle an xml packet
 private void XmlReceive(int count)
 {
     // Look for a 0 at the end.
     for (int i = _packetPos; i < _packetPos + count; i++)
     {
         if (_packet[i] != 0) continue;
         // Extract the xml
         string xml = Encoding.UTF8.GetString(_packet, 0, i);
         // Invoke the handler
         if (_xmlHandler != null)
             Program.Dispatcher.BeginInvoke(DispatcherPriority.Normal, _xmlHandler, xml);
         // Switch to a binary handler if the message asked for it
         if (xml == "<Binary />")
         {
             _binHandler = _handler.ReceiveMessage;
             _xmlHandler = null;
         }
         // Adjust the packet buffer
         count += _packetPos - i - 1;
         _packetPos = 0;
         Array.Copy(_packet, i + 1, _packet, 0, count);
         i = -1;
     }
     // Adjust the position in the packet buffer
     _packetPos += count;
 }