Esempio n. 1
0
        public static NextServer CreateServer(FizzySteamworks transport, int maxConnections)
        {
            NextServer s = new NextServer(maxConnections);

            s.OnConnected     += (id) => transport.OnServerConnected.Invoke(id);
            s.OnDisconnected  += (id) => transport.OnServerDisconnected.Invoke(id);
            s.OnReceivedData  += (id, data, ch) => transport.OnServerDataReceived.Invoke(id, new ArraySegment <byte>(data), ch);
            s.OnReceivedError += (id, exception) => transport.OnServerError.Invoke(id, exception);

            try
            {
#if UNITY_SERVER
                SteamGameServerNetworkingUtils.InitRelayNetworkAccess();
#else
                SteamNetworkingUtils.InitRelayNetworkAccess();
#endif
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }

            s.Host();

            return(s);
        }
Esempio n. 2
0
        public static NextServer CreateServer(FizzyFacepunch transport, int maxConnections)
        {
            NextServer s = new NextServer(maxConnections);

            s.OnConnected     += (id) => transport.OnServerConnected.Invoke(id);
            s.OnDisconnected  += (id) => transport.OnServerDisconnected.Invoke(id);
            s.OnReceivedData  += (id, data, ch) => transport.OnServerDataReceived.Invoke(id, new ArraySegment <byte>(data), ch);
            s.OnReceivedError += (id, exception) => transport.OnServerError.Invoke(id, exception);

            if (!SteamClient.IsValid)
            {
                Debug.LogError("SteamWorks not initialized.");
            }

            s.Host();

            return(s);
        }