Пример #1
0
        public NetManager()
        {
            statistics             = new NetStatistics(this);
            netManagerCreationTime = DateTime.UtcNow;
            netMessageHandler      = new NetMessageHandler(this);
            netWorld = new NetWorld(this);

            p2pSessionRequestCallback =
                Steamworks.Callback <Steamworks.P2PSessionRequest_t> .Create(
                    OnP2PSessionRequest);

            p2pConnectFailCallback =
                Steamworks.Callback <Steamworks.P2PSessionConnectFail_t> .Create(
                    OnP2PConnectFail);

            gameLobbyJoinRequestedCallback =
                Steamworks.Callback <Steamworks.GameLobbyJoinRequested_t> .Create(
                    OnGameLobbyJoinRequested);

            lobbyCreatedCallResult =
                new Steamworks.CallResult <Steamworks.LobbyCreated_t>(OnLobbyCreated);
            lobbyEnterCallResult =
                new Steamworks.CallResult <Steamworks.LobbyEnter_t>(OnLobbyEnter);

            Instance = this;

            RegisterProtocolMessagesHandlers();
        }
Пример #2
0
        public NetManager()
        {
            Instance               = this;
            statistics             = new NetStatistics(this);
            netManagerCreationTime = DateTime.UtcNow;
            netMessageHandler      = new NetMessageHandler(this);
            netWorld               = new NetWorld(this);

            // Hopefully this will fix people playing with different mod versions!
            string versionFull = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
            int    buildNumber = Convert.ToInt32(versionFull.Substring(versionFull.LastIndexOf('.') + 1));

            PROTOCOL_VERSION = buildNumber;
            Logger.Log("Build version is: " + PROTOCOL_VERSION);

            p2pSessionRequestCallback = Steamworks.Callback <Steamworks.P2PSessionRequest_t> .Create(OnP2PSessionRequest);

            p2pConnectFailCallback = Steamworks.Callback <Steamworks.P2PSessionConnectFail_t> .Create(OnP2PConnectFail);

            gameLobbyJoinRequestedCallback = Steamworks.Callback <Steamworks.GameLobbyJoinRequested_t> .Create(OnGameLobbyJoinRequested);

            lobbyCreatedCallResult = new Steamworks.CallResult <Steamworks.LobbyCreated_t>(OnLobbyCreated);
            lobbyEnterCallResult   = new Steamworks.CallResult <Steamworks.LobbyEnter_t>(OnLobbyEnter);
            lobbyListResult        = new Steamworks.CallResult <Steamworks.LobbyMatchList_t>(OnLobbyList);
            lobbyDataResult        = new Steamworks.CallResult <Steamworks.LobbyDataUpdate_t>(OnGetLobbyInfo);

            RegisterProtocolMessagesHandlers();

            RequestLobbies();
        }