Example #1
0
 public override bool Bind (UdpEndPoint endpoint) {
     try {
         socket.Bind(ConvertEndPoint(endpoint));
         return true;
     } catch (SocketException exn) {
         socketError = exn.SocketErrorCode;
         return false;
     }
 }
 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);
     }
 }
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);
        }
Example #4
0
    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");
        }
    }
Example #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);
        }
    }
Example #6
0
        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;
        }
    // 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);
    }
Example #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);
        }
Example #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);
        }
Example #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());
    }
    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.");
        }
    }
Example #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");
    }
 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;
     }
 }
Example #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);
    }
Example #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);
        }
Example #16
0
 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)
     {
     }
 }
Example #17
0
        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();
        }
Example #18
0
 public override void ConnectRequest(UdpEndPoint endpoint, IProtocolToken token)
 {
     BoltNetwork.Accept(endpoint);
 }
Example #19
0
 public static void StartClient(UdpEndPoint endpoint)
 {
     BoltLauncher.StartClient(endpoint, BoltRuntimeSettings.instance.GetConfigCopy());
 }
Example #20
0
 public override int SendTo(byte[] buffer, int bytesToSend, UdpEndPoint endpoint)
 {
     return bytesToSend;
 }
 static void Initialize(BoltNetworkModes modes, UdpEndPoint endpoint, BoltConfig config)
 {
     Initialize(modes, endpoint, config, null);
 }
Example #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);
 }
Example #23
0
 public abstract bool SendTo(byte[] buffer, int bytesToSend, UdpEndPoint endpoint, ref int bytesSent);
Example #24
0
    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;
        }
    }
Example #25
0
        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;
        }
 public override void ConnectAttempt(UdpEndPoint endpoint, IProtocolToken token)
 {
     UnityEngine.Debug.Log("ConnectAttempt");
     base.CancelInvoke("OnDisconnected");
     base.Invoke("OnDisconnected", (float)(6 * this._connectionAttempts));
 }
 public static void StartServer(UdpEndPoint endpoint, string scene)
 {
     StartServer(endpoint, BoltRuntimeSettings.instance.GetConfigCopy(), scene);
 }
 public static void StartClient(UdpEndPoint endpoint, BoltConfig config)
 {
     Initialize(BoltNetworkModes.Client, endpoint, config);
 }
 public static void StartClient(UdpEndPoint endpoint)
 {
     StartClient(endpoint, BoltRuntimeSettings.instance.GetConfigCopy());
 }
    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);
    }
Example #31
0
	public override int RecvFrom(byte[] buffer, int bufferSize, ref UdpEndPoint remoteEndpoint)
	{
		return 0;
	}
Example #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");
        }
Example #33
0
 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;
     }
 }
Example #34
0
 public override void ConnectRefused(UdpEndPoint endpoint, IProtocolToken token)
 {
     BoltLog.Warn("Connect Refused");
     base.ConnectRefused(endpoint, token);
 }
Example #35
0
    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);
        }
    }
Example #36
0
 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);
 }
Example #37
0
 public static extern Int32 Bind(IntPtr socket, UdpEndPoint.Native addr);
Example #38
0
 public override int RecvFrom(byte[] buffer, int bufferSize, ref UdpEndPoint remoteEndpoint)
 {
     return 0;
 }
Example #39
0
 public static extern Int32 SendTo(IntPtr socket, [Out] byte[] buffer, int size, UdpEndPoint.Native addr);
 public override void ConnectFailed(UdpEndPoint endpoint, IProtocolToken token)
 {
     BoltConsole.Write("ConnectFailed", Color.red);
     base.ConnectFailed(endpoint, token);
 }
Example #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;
 }
Example #42
0
 public override void Bind(UdpEndPoint ep)
 {
     this.bound   = true;
     this.steamId = ep.SteamId;
 }
Example #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;
     }
 }
Example #44
0
 public static void StartClient(UdpEndPoint endpoint, BoltConfig config)
 {
     BoltLauncher.Initialize(BoltNetworkModes.Client, endpoint, config);
 }
Example #45
0
 public override bool Bind (UdpEndPoint endpoint) {
     return UdpNativeInvoke.udpBind(ptr, endpoint) == UdpNativeInvoke.UDPKIT_SOCKET_OK;
 }
Example #46
0
	public override void Bind(UdpEndPoint ep)
	{
	}
Example #47
0
        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;
        }
Example #48
0
	public override int SendTo(byte[] buffer, int bytesToSend, UdpEndPoint endpoint)
	{
		return bytesToSend;
	}
Example #49
0
 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);
 }
Example #50
0
 public void Event_ConnectRequest(UdpEndPoint endpoint, IProtocolToken token)
 {
     Log.Info(LogChannel, "[PhotonNetworkInterface] ConnectRequest: " + endpoint.Address + "  port: " + endpoint.Port);
 }
Example #51
0
 public static void StartServer(UdpEndPoint endpoint)
 {
     StartServer(endpoint, BoltRuntimeSettings.instance.GetConfigCopy());
 }
Example #52
0
 public override void ConnectAttempt(UdpEndPoint endpoint, IProtocolToken token)
 {
     base.ConnectAttempt(endpoint, token);
     Debug.Log("ConnectAttempt");
 }
Example #53
0
 public static void StartServer(UdpEndPoint endpoint, BoltConfig config)
 {
     Initialize(BoltNetworkModes.Server, endpoint, config);
 }
Example #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);
    }
Example #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;
            }
        }
Example #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);
 }
Example #57
0
 public override void Bind(UdpEndPoint ep)
 {
 }
Example #58
0
 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));
     }
 }
 public static void StartServer(UdpEndPoint endpoint, BoltConfig config, string scene)
 {
     Initialize(BoltNetworkModes.Host, endpoint, config, scene);
 }