예제 #1
0
        public override void Connect()
        {
            try {
                // Debugger.Log ("socket2 begin connect");
                ReadyState = Connecting;
                var state = new SocketStateObject {
                    udpClient = _udpClient, endPoint = _endPoint
                };

                _udpClient.Connect(this._url, this._port);
                if (_udpClient.Connected())
                {
                    _kcp = new Kcp.Kcp(123, this);
                    _kcp.SetOutput(OutputKcp);

                    // fast mode
                    _kcp.NoDelay(1, 10, 2, 1);
                    _kcp.WndSize(1024, 1024);

                    Timer.SetTimer(() => StartKcpUpdate(), Config.K);

                    this.StartReceive();
                    ReadyState = Open;
                    base.onOpen();
                }
            } catch (Exception e) {
                Debugger.Log(e.ToString());
                PushError(e);
            }
        }
예제 #2
0
 void OnGUI()
 {
     GUILayout.BeginArea(new Rect(5, 5, 150, 400));
     GUILayout.Label("Client:");
     if (GUILayout.Button("Connect 127.0.0.1"))
     {
         client.Connect("127.0.0.1", Port, true, 10);
     }
     if (GUILayout.Button("Send 0x01, 0x02"))
     {
         client.Send(new ArraySegment <byte>(new byte[] { 0x01, 0x02 }));
     }
     if (GUILayout.Button("Disconnect"))
     {
         client.Disconnect();
     }
     GUILayout.EndArea();
 }
예제 #3
0
 // connect and give it enough time to handle
 void ConnectClientBlocking()
 {
     client.Connect("127.0.0.1", Port, NoDelay, Interval, 0, true, clientSendWindowSize, clientReceiveWindowSize);
     UpdateSeveralTimes();
 }
예제 #4
0
 // connect and give it enough time to handle
 void ConnectClientBlocking(string hostname = "127.0.0.1")
 {
     client.Connect(hostname, Port, NoDelay, Interval, 0, true, SendWindowSize, ReceiveWindowSize, Timeout, MaxRetransmits);
     UpdateSeveralTimes();
 }
예제 #5
0
 public override void ClientConnect(string address)
 {
     client.Connect(address, Port, NoDelay, Interval, FastResend, CongestionWindow, SendWindowSize, ReceiveWindowSize);
 }
예제 #6
0
 public static void Connect(string address, int port) => client.Connect(address, Port, NoDelay, Interval, FastResend, CongestionWindow, SendWindowSize, ReceiveWindowSize);