static void NewLink(KcpUser linker, DataBuffer data) { byte[] dat = data.fakeStruct.GetData <byte[]>(Req.Args); if (dat != null) { var link = KcpPack.UnPackMsg <LinkInfo>(dat); if (link != null) { new IPAddress(link.ip.ToBytes()); IPEndPoint endPoint = new IPEndPoint(new IPAddress(link.ip.ToBytes()), link.port); KcpServer.Instance.Send(new byte[1], EnvelopeType.Mate, endPoint); } } }
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; } }
static void RedirectServer(KcpUser linker, DataBuffer data) { try { byte[] dat = data.fakeStruct.GetData <byte[]>(Req.Args); var rs = KcpPack.UnPackMsg <RServer>(dat); if (rs != null) { if (rs.key == key) { ServerTable.AddServer(linker.ip, linker.port, rs.name); } } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } }