コード例 #1
0
            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);
                }
            }
コード例 #2
0
    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);
    }
コード例 #3
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);
            }
コード例 #4
0
ファイル: RaknetBase.cs プロジェクト: tonyyzz/RakUdpP2P
        protected RaknetIPAddress GetMyAddress()
        {
            SystemAddress systemAddress = rakPeer.GetMyBoundAddress();

            return(new RaknetIPAddress(systemAddress.ToString(false), systemAddress.GetPort()));
        }