Esempio n. 1
0
        public static LegacyClient CreateClient(FizzySteamworks transport, string host)
        {
            LegacyClient c = new LegacyClient(transport);

            c.OnConnected    += () => transport.OnClientConnected.Invoke();
            c.OnDisconnected += () => transport.OnClientDisconnected.Invoke();
            c.OnReceivedData += (data, channel) => transport.OnClientDataReceived.Invoke(new ArraySegment <byte>(data), channel);


            try
            {
#if UNITY_SERVER
                InteropHelp.TestIfAvailableGameServer();
#else
                InteropHelp.TestIfAvailableClient();
#endif
                c.Connect(host);
            }
            catch
            {
                Debug.LogError("SteamWorks not initialized.");
                c.OnConnectionFailed(CSteamID.Nil);
            }

            return(c);
        }
Esempio n. 2
0
        public static NextClient CreateClient(FizzySteamworks transport, string host)
        {
            NextClient c = new NextClient(transport);

            c.OnConnected    += () => transport.OnClientConnected.Invoke();
            c.OnDisconnected += () => transport.OnClientDisconnected.Invoke();
            c.OnReceivedData += (data, ch) => transport.OnClientDataReceived.Invoke(new ArraySegment <byte>(data), ch);

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

            return(c);
        }
Esempio n. 3
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. 4
0
        protected Common(FizzySteamworks transport)
        {
            channels = transport.Channels;

            callback_OnNewConnection = Callback <P2PSessionRequest_t> .Create(OnNewConnection);

            callback_OnConnectFail = Callback <P2PSessionConnectFail_t> .Create(OnConnectFail);

            this.transport = transport;
        }
        public static LegacyServer CreateServer(FizzySteamworks transport, int maxConnections)
        {
            LegacyServer s = new LegacyServer(transport, maxConnections);

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

            if (!SteamManager.Initialized)
            {
                Debug.LogError("SteamWorks not initialized.");
            }

            return(s);
        }
Esempio n. 6
0
        public static NextClient CreateClient(FizzySteamworks transport, string host)
        {
            NextClient c = new NextClient(transport);

            c.OnConnected    += () => transport.OnClientConnected.Invoke();
            c.OnDisconnected += () => transport.OnClientDisconnected.Invoke();
            c.OnReceivedData += (data, ch) => transport.OnClientDataReceived.Invoke(new ArraySegment <byte>(data), ch);

            if (SteamManager.Initialized)
            {
                c.Connect(host);
            }
            else
            {
                Debug.LogError("SteamWorks not initialized");
                c.OnConnectionFailed();
            }

            return(c);
        }
Esempio n. 7
0
        public static LegacyServer CreateServer(FizzySteamworks transport, int maxConnections)
        {
            LegacyServer s = new LegacyServer(transport, maxConnections);

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

            try
            {
#if UNITY_SERVER
                InteropHelp.TestIfAvailableGameServer();
#else
                InteropHelp.TestIfAvailableClient();
#endif
            }
            catch
            {
                Debug.LogError("SteamWorks not initialized.");
            }

            return(s);
        }
Esempio n. 8
0
 private LegacyClient(FizzySteamworks transport) : base(transport)
 {
     ConnectionTimeout = TimeSpan.FromSeconds(Math.Max(1, transport.Timeout));
 }
Esempio n. 9
0
 private NextClient(FizzySteamworks transport)
 {
     ConnectionTimeout = TimeSpan.FromSeconds(Math.Max(1, transport.Timeout));
     BufferedData      = new List <Action>();
 }
Esempio n. 10
0
 private LegacyServer(FizzySteamworks transport, int maxConnections) : base(transport)
 {
     this.maxConnections = maxConnections;
     steamToMirrorIds    = new BidirectionalDictionary <CSteamID, int>();
     nextConnectionID    = 1;
 }