コード例 #1
0
 public override bool Bind (UdpEndPoint endpoint) {
     try {
         socket.Bind(ConvertEndPoint(endpoint));
         return true;
     } catch (SocketException exn) {
         socketError = exn.SocketErrorCode;
         return false;
     }
 }
コード例 #2
0
 public override void ConnectFailed(UdpEndPoint endpoint, IProtocolToken token)
 {
     if (this.gui)
     {
         this.gui.SetErrorText("Could not connect to server (attempt " + this._connectionAttempts + "/3)");
     }
     else
     {
         UnityEngine.Debug.LogError("could not connect to dedicated server: " + this.dedicatedHostEndPoint);
     }
 }
コード例 #3
0
partial         void DelayPacket(UdpEndPoint ep, byte[] data, int length)
        {
            uint pingMin = (uint) Config.SimulatedPingMin;
            uint pingMax = (uint) Config.SimulatedPingMax;
            uint delay =  pingMin + (uint) ((pingMax - pingMin) * Config.NoiseFunction());

            DelayedPacket packet = new DelayedPacket();
            packet.Data = delayedBuffers.Count > 0 ? delayedBuffers.Dequeue() : new byte[Config.PacketSize * 2];
            packet.EndPoint = ep;
            packet.Length = length;
            packet.Time = GetCurrentTime() + delay;

            // copy entire buffer into packets data buffer
            Array.Copy(data, 0, packet.Data, 0, data.Length);

            // put on delay queue
            delayedPackets.Enqueue(packet);
        }
コード例 #4
0
ファイル: BoltDebugStart.cs プロジェクト: zond/dogspace-old-2
    void Start()
    {
        #if UNITY_EDITOR_OSX
        Process p = new Process();
        p.StartInfo.FileName = "osascript";
        p.StartInfo.Arguments =

        @"-e 'tell application """ + UnityEditor.PlayerSettings.productName + @"""
          activate
        end tell'";

        p.Start();
        #endif

        _serverEndPoint = new UdpEndPoint(UdpIPv4Address.Localhost, (ushort)BoltRuntimeSettings.instance.debugStartPort);
        _clientEndPoint = new UdpEndPoint(UdpIPv4Address.Localhost, 0);

        BoltConfig cfg;

        cfg = BoltRuntimeSettings.instance.GetConfigCopy();
        cfg.connectionTimeout = 60000000;
        cfg.connectionRequestTimeout = 500;
        cfg.connectionRequestAttempts = 1000;

        if (string.IsNullOrEmpty(BoltRuntimeSettings.instance.debugStartMapName) == false) {
          if (BoltDebugStartSettings.startServer) {
        BoltLauncher.StartServer(_serverEndPoint, cfg);
          }
          else if (BoltDebugStartSettings.startClient) {
        BoltLauncher.StartClient(_clientEndPoint, cfg);
          }

          BoltDebugStartSettings.PositionWindow();
        }
        else {
          BoltLog.Error("No map found to start from");
        }

        if (!BoltNetwork.isClient && !BoltNetwork.isServer) {
          BoltLog.Error("failed to start debug mode");
        }
    }
コード例 #5
0
    public override void BoltStartDone()
    {
        if (BoltNetwork.IsClient)
        {
#if !BOLT_CLOUD
            UdpEndPoint endPoint = new UdpEndPoint(UdpIPv4Address.Parse(serverAddress), (ushort)serverPort);

            RoomProtocolToken token = new RoomProtocolToken
            {
                ArbitraryData = "Room Token"
            };

            BoltNetwork.Connect(endPoint, token);
#endif
        }
        else
        {
            BoltNetwork.LoadScene(map);
        }
    }
コード例 #6
0
ファイル: udpConnection.cs プロジェクト: jbruening/udpkit
        internal UdpConnection(UdpSocket s, UdpConnectionMode m, UdpEndPoint ep, object hm)
        {
            socket      = s;
            mode        = m;
            endpoint    = ep;
            hailMessage = hm;

            stats         = new UdpStats();
            networkRtt    = socket.Config.DefaultNetworkPing;
            aliasedRtt    = socket.Config.DefaultAliasedPing;
            mtu           = socket.Config.PacketSize;
            alwaysSendMtu = socket.Config.DefaultAlwaysSendMtu;
            state         = UdpConnectionState.Connecting;
            recvTime      = socket.GetCurrentTime();
            sendTime      = recvTime;
            sendWindow    = new UdpRingBuffer <UdpHandle>(socket.Config.PacketWindow);

            serializer            = socket.CreateSerializer();
            serializer.Connection = this;
        }
コード例 #7
0
    // Host a server
    public static void HostLobby(LobbySettings settings)
    {
        // If already connected, Bolt needs to be shutdown before joining a server
        if (IsHost || IsClient)
        {
            Debug.Log("Shutting down client...");
            BoltLauncher.Shutdown();
        }

        Debug.Log("...Restarting as Host");

        BoltConfig lobbySettings = new BoltConfig();

        lobbySettings.useNetworkSimulation       = settings.DEVSimulateNetworkCondition;
        lobbySettings.simulatedPingMean          = settings.DEVPingMean;
        lobbySettings.simulatedPingJitter        = settings.DEVPingJitter;
        lobbySettings.serverConnectionAcceptMode = BoltConnectionAcceptMode.Auto;

        BoltLauncher.StartServer(UdpEndPoint.Parse("0.0.0.0:27000"), lobbySettings);
    }
コード例 #8
0
        public void CommsServer_SendMessageSendsOnUnicastSocket()
        {
            var socketFactory = new MockSocketFactory();
            var server        = new SsdpCommunicationsServer(socketFactory);

            string      message     = "Hello!";
            UdpEndPoint destination = new UdpEndPoint()
            {
                IPAddress = "192.168.1.100", Port = 1701
            };

            server.SendMessage(System.Text.UTF8Encoding.UTF8.GetBytes(message), destination);

            Assert.IsNotNull(socketFactory.UnicastSocket);

            var mockSocket = socketFactory.UnicastSocket as MockSocket;

            Assert.AreEqual(message, System.Text.UTF8Encoding.UTF8.GetString(mockSocket.LastMessage));
            Assert.AreEqual(destination.IPAddress, mockSocket.LastSentTo.IPAddress);
            Assert.AreEqual(destination.Port, mockSocket.LastSentTo.Port);
        }
コード例 #9
0
        public void CommsServer_StopListeningForResponsesDisposesUnicastSocket()
        {
            var socketFactory = new MockSocketFactory();
            var server        = new SsdpCommunicationsServer(socketFactory);

            string      message     = "Hello!";
            UdpEndPoint destination = new UdpEndPoint()
            {
                IPAddress = "192.168.1.100", Port = 1701
            };

            server.SendMessage(System.Text.UTF8Encoding.UTF8.GetBytes(message), destination);

            var mockSocket = socketFactory.UnicastSocket as MockSocket;

            Assert.IsFalse(mockSocket.IsDisposed);

            server.StopListeningForResponses();

            Assert.IsTrue(mockSocket.IsDisposed);
        }
コード例 #10
0
    static void Initialize(BoltNetworkModes modes, UdpEndPoint endpoint, BoltConfig config)
    {
        BoltNetworkInternal.DebugDrawer = new BoltInternal.UnityDebugDrawer();

#if UNITY_PRO_LICENSE
        BoltNetworkInternal.UsingUnityPro = true;
#else
        BoltNetworkInternal.UsingUnityPro = false;
#endif

#if BOLT_UPNP_SUPPORT
        BoltNetworkInternal.NatCommunicator = new BoltInternal.StandaloneNatCommunicator();
#endif

        BoltNetworkInternal.GetSceneName            = GetSceneName;
        BoltNetworkInternal.GetSceneIndex           = GetSceneIndex;
        BoltNetworkInternal.GetGlobalBehaviourTypes = GetGlobalBehaviourTypes;
        BoltNetworkInternal.EnvironmentSetup        = BoltInternal.BoltNetworkInternal_User.EnvironmentSetup;
        BoltNetworkInternal.EnvironmentReset        = BoltInternal.BoltNetworkInternal_User.EnvironmentReset;
        BoltNetworkInternal.__Initialize(modes, endpoint, config, CreateUdpPlatform());
    }
コード例 #11
0
    public unsafe override void ConnectRequest(UdpEndPoint endpoint, Bolt.IProtocolToken token)
    {
        SteamConnectToken connectToken = token as SteamConnectToken;

        BeginAuthResult result = SteamUser.BeginAuthSession(connectToken.ticket, connectToken.steamid);

        if (result == BeginAuthResult.OK)
        {
            if (pendingConnections.ContainsKey(connectToken.steamid))
            {
                pendingConnections.Remove(connectToken.steamid);
            }

            pendingConnections.Add(connectToken.steamid, endpoint);
        }
        else
        {
            BoltNetwork.Refuse(endpoint);
            BoltLog.Info("Refused user with invalid ticket.");
        }
    }
コード例 #12
0
    public void OnClientContinueGameDS(gameserveritem_t server)
    {
        Debug.Log("Starting dedicated client");
        SteamDSConfig.isDedicatedServer       = false;
        CoopPeerStarter.DedicatedHost         = false;
        SteamClientDSConfig.isDedicatedClient = true;
        string[] array = server.GetGameTags().Split(new char[]
        {
            ';'
        });
        string guid = (array == null || array.Length <= 0) ? string.Empty : array[0];

        SteamClientDSConfig.Guid          = guid;
        SteamClientDSConfig.Server        = server;
        SteamClientDSConfig.serverAddress = server.m_NetAdr.GetConnectionAddressString();
        if (!string.IsNullOrEmpty(this._joinDsScreen._password.value))
        {
            SteamClientDSConfig.password       = SteamDSConfig.PasswordToHash(this._joinDsScreen._password.value);
            this._joinDsScreen._password.value = string.Empty;
        }
        else
        {
            SteamClientDSConfig.password = string.Empty;
        }
        if (!string.IsNullOrEmpty(this._joinDsScreen._adminPassword.value))
        {
            SteamClientDSConfig.adminPassword       = SteamDSConfig.PasswordToHash(this._joinDsScreen._adminPassword.value);
            this._joinDsScreen._adminPassword.value = string.Empty;
        }
        else
        {
            SteamClientDSConfig.adminPassword = string.Empty;
        }
        SteamClientDSConfig.EndPoint = UdpEndPoint.Parse(SteamClientDSConfig.serverAddress);
        GameSetup.SetInitType(InitTypes.Continue);
        UnityEngine.Object.Destroy(base.gameObject);
        SceneManager.LoadScene("SteamStartSceneDedicatedServer_Client");
    }
コード例 #13
0
 public void TestButton()
 {
     if (BoltNetwork.SessionList.Count > 0)
     {
         Debug += "\nSession found. Attempting connection";
         UdpSession session = null;
         foreach (var s in BoltNetwork.SessionList)
         {
             session = s.Value;
             break;
         }
         if (session != null)
         {
             UdpEndPoint endpoint = UdpEndPoint.Parse(session.LanEndPoint.Address + ":" + localPort);
             Debug += "\nEnd Point: " + session.LanEndPoint.Address + ":" + localPort;
             BoltNetwork.Connect(endpoint);
         }
     }
     else
     {
         Debug += "\nNo session found." + BoltNetwork.SessionList.Count;
     }
 }
コード例 #14
0
    public override int RecvFrom(byte[] buffer, int bufferSize, ref UdpEndPoint endpoint)
    {
        int result;

        try
        {
            int num = this.socket.ReceiveFrom(buffer, 0, bufferSize, SocketFlags.None, ref this.recvEndPoint);
            if (num > 0)
            {
                endpoint = DotNetPlatform.ConvertEndPoint(this.recvEndPoint);
                result   = num;
            }
            else
            {
                result = -1;
            }
        }
        catch (SocketException exn)
        {
            this.HandleSocketException(exn);
            result = -1;
        }
        return(result);
    }
コード例 #15
0
        public override void ConnectRequest(UdpEndPoint endpoint, IProtocolToken token)
        {
            base.ConnectRequest(endpoint, token);

            if (!(token is ClientConnectionToken clientToken))
            {
                BoltNetwork.Refuse(endpoint, new ClientRefuseToken(ConnectRefusedReason.InvalidToken));
                return;
            }

            if (clientToken.UnityId == SystemInfo.unsupportedIdentifier)
            {
                BoltNetwork.Refuse(endpoint, new ClientRefuseToken(ConnectRefusedReason.UnsupportedDevice));
                return;
            }

            if (clientToken.Version != ServerToken.Version)
            {
                BoltNetwork.Refuse(endpoint, new ClientRefuseToken(ConnectRefusedReason.InvalidVersion));
                return;
            }

            BoltNetwork.Accept(endpoint);
        }
コード例 #16
0
ファイル: BoltDebugStart.cs プロジェクト: GameDiffs/TheForest
 private void Start()
 {
     this._serverEndPoint = new UdpEndPoint(UdpIPv4Address.Localhost, (ushort)BoltRuntimeSettings.instance.debugStartPort);
     this._clientEndPoint = new UdpEndPoint(UdpIPv4Address.Localhost, 0);
     BoltConfig configCopy = BoltRuntimeSettings.instance.GetConfigCopy();
     configCopy.connectionTimeout = 60000000;
     configCopy.connectionRequestTimeout = 500;
     configCopy.connectionRequestAttempts = 1000;
     if (!string.IsNullOrEmpty(BoltRuntimeSettings.instance.debugStartMapName))
     {
         if (BoltDebugStartSettings.startServer)
         {
             BoltLauncher.StartServer(this._serverEndPoint, configCopy);
         }
         else if (BoltDebugStartSettings.startClient)
         {
             BoltLauncher.StartClient(this._clientEndPoint, configCopy);
         }
         BoltDebugStartSettings.PositionWindow();
     }
     if (BoltNetwork.isClient || !BoltNetwork.isServer)
     {
     }
 }
コード例 #17
0
ファイル: MockCommsServer.cs プロジェクト: petermajor/RSSDP
        private void ProcessMessage(string data, UdpEndPoint endPoint)
        {
            //Responses start with the HTTP version, prefixed with HTTP/ while
            //requests start with a method which can vary and might be one we haven't
            //seen/don't know. We'll check if this message is a request or a response
            //by checking for the static HTTP/ prefix on the start of the message.
            if (data.StartsWith("HTTP/", StringComparison.OrdinalIgnoreCase))
            {
                HttpResponseMessage responseMessage = null;
                try
                {
                    responseMessage = _ResponseParser.Parse(data);
                }
                catch (ArgumentException) { }                 // Ignore invalid packets.

                if (responseMessage != null)
                {
                    OnResponseReceived(responseMessage, endPoint);
                }
            }
            else
            {
                HttpRequestMessage requestMessage = null;
                try
                {
                    requestMessage = _RequestParser.Parse(data);
                }
                catch (ArgumentException) { }                 // Ignore invalid packets.

                if (requestMessage != null)
                {
                    OnRequestReceived(requestMessage, endPoint);
                }
            }
            _MessageProcessedSignal.Set();
        }
コード例 #18
0
 public override void ConnectRequest(UdpEndPoint endpoint, IProtocolToken token)
 {
     BoltNetwork.Accept(endpoint);
 }
コード例 #19
0
ファイル: BoltLauncher.cs プロジェクト: K07H/The-Forest
 public static void StartClient(UdpEndPoint endpoint)
 {
     BoltLauncher.StartClient(endpoint, BoltRuntimeSettings.instance.GetConfigCopy());
 }
コード例 #20
0
ファイル: NullSocket.cs プロジェクト: zond/dogspace-old-2
 public override int SendTo(byte[] buffer, int bytesToSend, UdpEndPoint endpoint)
 {
     return bytesToSend;
 }
コード例 #21
0
 static void Initialize(BoltNetworkModes modes, UdpEndPoint endpoint, BoltConfig config)
 {
     Initialize(modes, endpoint, config, null);
 }
コード例 #22
0
 /// <summary>
 /// Starts Bolt as Server.
 /// </summary>
 /// <param name="endpoint">Custom EndPoint where Bolt will try to bind</param>
 /// <param name="scene">Default Scene loaded by Bolt when the initialization is complete</param>
 public static void StartServer(UdpEndPoint endpoint, string scene = null)
 {
     StartServer(endpoint, BoltRuntimeSettings.instance.GetConfigCopy(), scene);
 }
コード例 #23
0
ファイル: udpPlatform.cs プロジェクト: trecchia/udpkit
 public abstract bool SendTo(byte[] buffer, int bytesToSend, UdpEndPoint endpoint, ref int bytesSent);
コード例 #24
0
ファイル: DotNetSocket.cs プロジェクト: PeWiNi/gamedev15
    public override int RecvFrom(byte[] buffer, int bufferSize, ref UdpEndPoint endpoint)
    {
        try {
          int bytesReceived = socket.ReceiveFrom(buffer, 0, bufferSize, SocketFlags.None, ref recvEndPoint);

          if (bytesReceived > 0) {
        endpoint = DotNetPlatform.ConvertEndPoint(recvEndPoint);
        return bytesReceived;
          }
          else {
        return -1;
          }
        }
        catch (SocketException exn) {
          HandleSocketException(exn);
          return -1;
        }
    }
コード例 #25
0
ファイル: udpConnection.cs プロジェクト: karlgluck/udpkit
        internal UdpConnection(UdpSocket s, UdpConnectionMode m, UdpEndPoint ep)
        {
            socket = s;
            mode = m;
            endpoint = ep;
            stats = new UdpStats();
            networkRtt = socket.Config.DefaultNetworkPing;
            aliasedRtt = socket.Config.DefaultAliasedPing;
            mtu = socket.Config.PacketSize;
            alwaysSendMtu = socket.Config.DefaultAlwaysSendMtu;
            state = UdpConnectionState.Connecting;
            recvTime = socket.GetCurrentTime();
            sendTime = recvTime;
            sendWindow = new UdpRingBuffer<UdpHandle>(socket.Config.PacketWindow);

            this.networkPingFilterRttValues = new uint[socket.Config.NetworkPingMedianFilterSize];
            this.networkPingFilterSortedIndices = new int[socket.Config.NetworkPingMedianFilterSize];
            for (int i = 0; i < this.networkPingFilterSortedIndices.Length; ++i)
            {
                this.networkPingFilterSortedIndices[i] = i;
            }
            networkPingFilterNextIndexToReplace = 0;

            serializer = socket.CreateSerializer();
            serializer.Connection = this;
        }
コード例 #26
0
 public override void ConnectAttempt(UdpEndPoint endpoint, IProtocolToken token)
 {
     UnityEngine.Debug.Log("ConnectAttempt");
     base.CancelInvoke("OnDisconnected");
     base.Invoke("OnDisconnected", (float)(6 * this._connectionAttempts));
 }
コード例 #27
0
 public static void StartServer(UdpEndPoint endpoint, string scene)
 {
     StartServer(endpoint, BoltRuntimeSettings.instance.GetConfigCopy(), scene);
 }
コード例 #28
0
 public static void StartClient(UdpEndPoint endpoint, BoltConfig config)
 {
     Initialize(BoltNetworkModes.Client, endpoint, config);
 }
コード例 #29
0
 public static void StartClient(UdpEndPoint endpoint)
 {
     StartClient(endpoint, BoltRuntimeSettings.instance.GetConfigCopy());
 }
コード例 #30
0
    static void Initialize(BoltNetworkModes modes, UdpEndPoint endpoint, BoltConfig config, string scene)
    {
        BoltNetworkInternal.DebugDrawer = new BoltInternal.UnityDebugDrawer();

        #if UNITY_PRO_LICENSE
        BoltNetworkInternal.UsingUnityPro = true;
        #else
        BoltNetworkInternal.UsingUnityPro = false;
        #endif

        #if BOLT_UPNP_SUPPORT
        BoltNetworkInternal.NatCommunicator = new BoltInternal.StandaloneNatCommunicator();
        #endif

        BoltNetworkInternal.GetSceneName = GetSceneName;
        BoltNetworkInternal.GetSceneIndex = GetSceneIndex;
        BoltNetworkInternal.GetGlobalBehaviourTypes = GetGlobalBehaviourTypes;
        BoltNetworkInternal.EnvironmentSetup = BoltInternal.BoltNetworkInternal_User.EnvironmentSetup;
        BoltNetworkInternal.EnvironmentReset = BoltInternal.BoltNetworkInternal_User.EnvironmentReset;
        BoltNetworkInternal.__Initialize(modes, endpoint, config, CreateUdpPlatform(), scene);
    }
コード例 #31
0
	public override int RecvFrom(byte[] buffer, int bufferSize, ref UdpEndPoint remoteEndpoint)
	{
		return 0;
	}
コード例 #32
0
        public void Event_ConnectRefused(UdpEndPoint endpoint, IProtocolToken token)
        {
            Log.Info(LogChannel, "[PhotonNetworkInterface] ConnectRefused: " + endpoint.Address + "  port: " + endpoint.Port);

            ConcludeOperationCallback(ref _operationCallbackSessionConnected, false, "Connection refused");
        }
コード例 #33
0
ファイル: DotNetSocket.cs プロジェクト: PeWiNi/gamedev15
 public override int SendTo(byte[] buffer, int bytesToSend, UdpEndPoint endpoint)
 {
     try {
       return socket.SendTo(buffer, 0, bytesToSend, SocketFlags.None, DotNetPlatform.ConvertEndPoint(endpoint));
     }
     catch (SocketException exn) {
       HandleSocketException(exn);
       return -1;
     }
 }
コード例 #34
0
 public override void ConnectRefused(UdpEndPoint endpoint, IProtocolToken token)
 {
     BoltLog.Warn("Connect Refused");
     base.ConnectRefused(endpoint, token);
 }
コード例 #35
0
ファイル: DotNetSocket.cs プロジェクト: PeWiNi/gamedev15
    public override void Bind(UdpEndPoint ep)
    {
        try {
          error = null;
          socket.Bind(DotNetPlatform.ConvertEndPoint(ep));

          endpoint = DotNetPlatform.ConvertEndPoint(socket.LocalEndPoint);

          UdpLog.Info("Socket bound to {0}", endpoint);
        }
        catch (SocketException exn) {
          HandleSocketException(exn);
        }
    }
コード例 #36
0
ファイル: DotNetPlatform.cs プロジェクト: nixjoe/NetworkTest
 public static IPEndPoint ConvertEndPoint(UdpEndPoint endpoint) {
   return new IPEndPoint(new IPAddress(new byte[] { endpoint.Address.Byte3, endpoint.Address.Byte2, endpoint.Address.Byte1, endpoint.Address.Byte0 }), endpoint.Port);
 }
コード例 #37
0
ファイル: NativePInvoke.cs プロジェクト: PeWiNi/gamedev15
 public static extern Int32 Bind(IntPtr socket, UdpEndPoint.Native addr);
コード例 #38
0
ファイル: NullSocket.cs プロジェクト: zond/dogspace-old-2
 public override int RecvFrom(byte[] buffer, int bufferSize, ref UdpEndPoint remoteEndpoint)
 {
     return 0;
 }
コード例 #39
0
ファイル: NativePInvoke.cs プロジェクト: PeWiNi/gamedev15
 public static extern Int32 SendTo(IntPtr socket, [Out] byte[] buffer, int size, UdpEndPoint.Native addr);
コード例 #40
0
 public override void ConnectFailed(UdpEndPoint endpoint, IProtocolToken token)
 {
     BoltConsole.Write("ConnectFailed", Color.red);
     base.ConnectFailed(endpoint, token);
 }
コード例 #41
0
 IPEndPoint ConvertEndPoint (UdpEndPoint endpoint) {
     uint netOrder = (uint) IPAddress.HostToNetworkOrder((int) endpoint.Address.Packed);
     convertAddress.Address = netOrder;
     convertEndPoint.Address = convertAddress;
     convertEndPoint.Port = endpoint.Port;
     return convertEndPoint;
 }
コード例 #42
0
ファイル: SteamSocket.cs プロジェクト: DevZhav/The-Forest
 public override void Bind(UdpEndPoint ep)
 {
     this.bound   = true;
     this.steamId = ep.SteamId;
 }
コード例 #43
0
 public override bool SendTo (byte[] buffer, int bytesToSend, UdpEndPoint endpoint, ref int bytesSent) {
     try {
         bytesSent = socket.SendTo(buffer, 0, bytesToSend, SocketFlags.None, ConvertEndPoint(endpoint));
         return bytesSent == bytesToSend;
     } catch (SocketException exn) {
         socketError = exn.SocketErrorCode;
         return false;
     }
 }
コード例 #44
0
ファイル: BoltLauncher.cs プロジェクト: K07H/The-Forest
 public static void StartClient(UdpEndPoint endpoint, BoltConfig config)
 {
     BoltLauncher.Initialize(BoltNetworkModes.Client, endpoint, config);
 }
コード例 #45
0
ファイル: udpPlatformNative.cs プロジェクト: karlgluck/udpkit
 public override bool Bind (UdpEndPoint endpoint) {
     return UdpNativeInvoke.udpBind(ptr, endpoint) == UdpNativeInvoke.UDPKIT_SOCKET_OK;
 }
コード例 #46
0
	public override void Bind(UdpEndPoint ep)
	{
	}
コード例 #47
0
ファイル: udpPlatformNative.cs プロジェクト: karlgluck/udpkit
        public override bool RecvFrom (byte[] buffer, int bufferSize, ref int bytesReceived, ref UdpEndPoint remoteEndpoint) {
            UdpEndPoint nativeEndpoint = default(UdpEndPoint);

            fixed (byte* p = buffer) {
                bytesReceived = UdpNativeInvoke.udpRecvFrom(ptr, new IntPtr(p), bufferSize, &nativeEndpoint);
            }

            if (bytesReceived > 0) {
                remoteEndpoint = nativeEndpoint;
                return true;
            }

            return false;
        }
コード例 #48
0
	public override int SendTo(byte[] buffer, int bytesToSend, UdpEndPoint endpoint)
	{
		return bytesToSend;
	}
コード例 #49
0
ファイル: udpConnection.cs プロジェクト: trecchia/udpkit
 internal UdpConnection(UdpSocket sock, UdpConnectionMode m, UdpEndPoint ep)
 {
     socket = sock;
     mode = m;
     endpoint = ep;
     networkRtt = socket.Config.DefaultNetworkPing;
     aliasedRtt = socket.Config.DefaultAliasedPing;
     mtu = sock.Config.DefaultMtu;
     alwaysSendMtu = sock.Config.DefaultAlwaysSendMtu;
     serializer = sock.CreateSerializer();
     state = UdpConnectionState.Connecting;
     recvTime = socket.GetCurrentTime();
     sendTime = recvTime;
     stats = new UdpConnectionStats();
     sendWindow = new UdpRingBuffer<UdpHandle>(sock.Config.PacketWindow);
 }
コード例 #50
0
 public void Event_ConnectRequest(UdpEndPoint endpoint, IProtocolToken token)
 {
     Log.Info(LogChannel, "[PhotonNetworkInterface] ConnectRequest: " + endpoint.Address + "  port: " + endpoint.Port);
 }
コード例 #51
0
 public static void StartServer(UdpEndPoint endpoint)
 {
     StartServer(endpoint, BoltRuntimeSettings.instance.GetConfigCopy());
 }
コード例 #52
0
 public override void ConnectAttempt(UdpEndPoint endpoint, IProtocolToken token)
 {
     base.ConnectAttempt(endpoint, token);
     Debug.Log("ConnectAttempt");
 }
コード例 #53
0
 public static void StartServer(UdpEndPoint endpoint, BoltConfig config)
 {
     Initialize(BoltNetworkModes.Server, endpoint, config);
 }
コード例 #54
0
    // Utils

    /// <summary>
    /// Utility function to initialize Bolt with the specified modes, endpoint, config and scene.
    /// </summary>
    /// <param name="modes">Bolt mode. <see cref="BoltNetworkModes"/></param>
    /// <param name="endpoint">Custom EndPoint where Bolt will try to bind</param>
    /// <param name="config">Custom Bolt configuration</param>
    /// <param name="scene">Default Scene loaded by Bolt when the initialization is complete</param>
    static void Initialize(BoltNetworkModes modes, UdpEndPoint endpoint, BoltConfig config, string scene = null)
    {
        BoltDynamicData.Setup();
        BoltNetworkInternal.Initialize(modes, endpoint, config, TargetPlatform, scene);
    }
コード例 #55
0
        public override bool RecvFrom (byte[] buffer, int bufferSize, ref int bytesReceived, ref UdpEndPoint remoteEndpoint) {
            try {
                bytesReceived = socket.ReceiveFrom(buffer, 0, bufferSize, SocketFlags.None, ref recvEndPoint);

                if (bytesReceived > 0) {
                    remoteEndpoint = ConvertEndPoint((IPEndPoint) recvEndPoint);
                    return true;
                } else {
                    return false;
                }
            } catch (SocketException exn) {
                socketError = exn.SocketErrorCode;
                return false;
            }
        }
コード例 #56
0
 /// <summary>
 /// Starts Bolt as Server.
 /// </summary>
 /// <param name="endpoint">Custom EndPoint where Bolt will try to bind</param>
 /// <param name="config">Custom Bolt configuration</param>
 /// <param name="scene">Default Scene loaded by Bolt when the initialization is complete</param>
 public static void StartServer(UdpEndPoint endpoint, BoltConfig config, string scene = null)
 {
     Initialize(BoltNetworkModes.Server, endpoint, config, scene);
 }
コード例 #57
0
ファイル: NullSocket.cs プロジェクト: zond/dogspace-old-2
 public override void Bind(UdpEndPoint ep)
 {
 }
コード例 #58
0
ファイル: udpPlatformNative.cs プロジェクト: karlgluck/udpkit
 public override bool SendTo (byte[] buffer, int bytesToSend, UdpEndPoint endpoint, ref int bytesSent) {
     fixed (byte* p = buffer) {
         return bytesToSend == (bytesSent = UdpNativeInvoke.udpSendTo(ptr, new IntPtr(p), bytesToSend, endpoint));
     }
 }
コード例 #59
0
 public static void StartServer(UdpEndPoint endpoint, BoltConfig config, string scene)
 {
     Initialize(BoltNetworkModes.Host, endpoint, config, scene);
 }