public static bool ReadConnection(PacketReader stream, RakNetGUID guid, SystemAddress ip, out GameClient client) { client = ScriptManager.Interface.CreateClient(); client.driveHash = stream.ReadBytes(16); client.macHash = stream.ReadBytes(16); if (client.ScriptObject.IsAllowedToConnect()) { client.guid = new RakNetGUID(guid.g); client.systemAddress = new SystemAddress(ip.ToString(), ip.GetPort()); return(true); } else { client = null; return(false); } }
public int Start(out string ip, out ushort port, ushort maxConnections) { this.server = RakPeer.GetInstance(); this.server.SetMaximumIncomingConnections(maxConnections); StartupResult result = this.server.Startup(maxConnections, new SocketDescriptor(), 1); SystemAddress adr = this.server.GetMyBoundAddress(); ip = adr.ToString(false); port = adr.GetPort(); Log.WriteLine(string.Format("监听server {0}:{1}", ip, port)); if (result != StartupResult.RAKNET_STARTED) { Log.WriteLine(string.Format("服务器启动失败 retCode:{0}", result)); return(-1); } return(0); }
public override void OnForwardingSuccess(string proxyIPAddress, ushort proxyPort, SystemAddress proxyCoordinator, SystemAddress sourceAddress, SystemAddress targetAddress, RakNetGUID targetGuid, UDPProxyClient proxyClientPlugin) { RaknetExtension.WriteInfo("▲▲▲OnForwardingSuccess"); _proxyServerAddress = new RaknetIPAddress(targetAddress.ToString(false), targetAddress.GetPort()); var peer = proxyClientPlugin.GetRakPeerInterface(); var systemAddress = peer.GetMyBoundAddress(); peer.Connect(_proxyServerAddress.Address, _proxyServerAddress.Port, "", 0); }
protected RaknetIPAddress GetMyAddress() { SystemAddress systemAddress = rakPeer.GetMyBoundAddress(); return(new RaknetIPAddress(systemAddress.ToString(false), systemAddress.GetPort())); }