예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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;
        }
예제 #5
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);

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

            return(s);
        }
예제 #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);
        }
예제 #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);
        }
예제 #8
0
 private LegacyClient(FizzySteamworks transport) : base(transport)
 {
     ConnectionTimeout = TimeSpan.FromSeconds(Math.Max(1, transport.Timeout));
 }
예제 #9
0
 private NextClient(FizzySteamworks transport)
 {
     ConnectionTimeout = TimeSpan.FromSeconds(Math.Max(1, transport.Timeout));
     BufferedData      = new List <Action>();
 }
예제 #10
0
 private LegacyServer(FizzySteamworks transport, int maxConnections) : base(transport)
 {
     this.maxConnections = maxConnections;
     steamToMirrorIds    = new BidirectionalDictionary <CSteamID, int>();
     nextConnectionID    = 1;
 }