/// <summary> /// 下层自上层的断开连接 /// 是否重连 /// </summary> private void CloseEventHandler() { if (state != WorldState.Closed) { kcpClient = new KCPClient(rc.GetMainLoop(), this); kcpClient.closeEventHandler = this.CloseEventHandler; kcpClient.Connect(ClientApp.Instance.remoteServerIP, ClientApp.Instance.remoteKCPPort); //重新初始化 食物的状态请求 } }
public void Start(string host, UInt16 port, uint index, int key) { client = new KCPClient(); client.Event += client_Event; client.Connect(host, port, index, key); while (true) { client.Update(); System.Threading.Thread.Sleep(30); } }
public void Conn(uint conv) { Clear(); switch (type) { case NetWorkType.Kcp: kcp.Connect(ip, port, conv); break; case NetWorkType.Tcp: tcp.ConnectAsync(ip, port); break; } }
public void StartUdp(int type) { if (type == 1) { if (udp == null) { udp = new UClient(this); udp.Handlers = tcp_handle; } } else if (type == 2) { kcp = new KCPClient(); kcp.Event += Client_Event; kcp.Connect("192.168.2.91", 7566, (uint)main.entity_id, main.entity_id); } }