コード例 #1
0
 void MessagePro(DataBuffer data)
 {
     switch (data.fakeStruct[Req.Cmd])
     {
     case ProCmd.ServerIp:
         byte[] dat = data.fakeStruct.GetData <byte[]>(Req.Args);
         var    rs  = KcpPack.UnPackMsg <ServerInfo>(dat);
         if (rs != null)
         {
             link.Redirect(rs.ip, rs.port);
             link.SendNull(DefCmd.heart, MessageType.Def);
         }
         break;
     }
 }
コード例 #2
0
        public void Connection(string ip, int port)
        {
            var address = IPAddress.Parse(ip);

            KcpServer.CreateLink = (o) => {
                return(new KcpSocket(o));
            };
            var kcp = new KcpServer(0, 0, 1);

            link = kcp.CreateNewLink(new IPEndPoint(address, port)) as KcpSocket;
            link.SendNull(ProCmd.ServerIp, MessageType.Pro);
            //LoginTable login = new LoginTable();
            //login.user = "******";
            //login.pass = "******";
            //Instance.SendObject<LoginTable>(DefCmd.Login, MessageType.Def, login);
        }