public void OnMatchCreate(CreateMatchResponse matchResponse)
        {
            if (matchResponse.success)
            {
                Debug.Log("Create match succeeded");

                Debug.Log(matchResponse.networkId);
                Debug.Log(Utility.GetSourceID().ToString());

                ConnectionConfig config = new ConnectionConfig();
                config.AddChannel(QosType.ReliableFragmented);
                config.AddChannel(QosType.UnreliableFragmented);

                NetworkServer.Configure(config, 3);

                NetworkServer.RegisterHandler(MsgType.Connect, OnPlayerConnected);
                NetworkServer.RegisterHandler(100, OnClientMessage);
                NetworkServer.Listen(new MatchInfo(matchResponse), 25000);

                Utility.SetAccessTokenForNetwork(matchResponse.networkId,
                                                 new NetworkAccessToken(matchResponse.accessTokenString));

                UnityMatchmaking.Instance.MasterServerConnection.matchMaker.JoinMatch(matchResponse.networkId, "",
                                                                                      OnServerMatchJoined);
                UnityMatchmaking.Instance.LastGameId = matchResponse.networkId;
            }
            else
            {
                Debug.LogError("Create match failed");
            }
        }
Example #2
0
        public void Handle(CreateMatchRequest request)
        {
            try
            {
                if (!String.IsNullOrEmpty(request.IdFirstTeam) || !String.IsNullOrEmpty(request.IdSecondTeam) || !String.IsNullOrEmpty(request.DateTimeMatch.ToString()))
                {
                    _matchRepo.Insert(new Match
                    {
                        FirstTeam         = GetTeamById(request.IdFirstTeam),
                        SecondTeam        = GetTeamById(request.IdSecondTeam),
                        DateTimeMatch     = request.DateTimeMatch,
                        ScoreOfFirstTeam  = 0,
                        ScoreOfSecondTeam = 0,
                        IsDeleted         = false
                    });

                    var response = new CreateMatchResponse(true);
                    Sender.Tell(response);
                    _logger.Info("Create Match successfull: {0} {1}", request.IdFirstTeam, request.IdSecondTeam);
                }
                else
                {
                    var response = new CreateMatchResponse(false);
                    Sender.Tell(response);
                    _logger.Error("Couldn't create Match: {0} {1}: All fields are required", request.IdFirstTeam, request.IdSecondTeam);
                }
            }
            catch (Exception ex)
            {
                var response = new CreateMatchResponse(false);
                Sender.Tell(response);
                _logger.Error("Couldn't create Match: {0} {1}: {2}", request.IdFirstTeam, request.IdSecondTeam, ex.Message);
            }
        }
Example #3
0
    /// <summary>Called when a UNET match is created. This is only used when relays are enabled.</summary>
#if UNITY_5_3
    void OnUNETMatchCreated(CreateMatchResponse response)
    {
        // Start hosting
        networkManager.OnMatchCreate(response);
        // Create the match
        CreateMatch();
    }
Example #4
0
 public CreatedMatchInformation(CreateMatchResponse response) : this(
         response.accessTokenString.GetByteString(),
         response.networkId,
         response.nodeId
         )
 {
 }
Example #5
0
 public override void OnMatchCreate(CreateMatchResponse matchInfo)
 {
     base.OnMatchCreate(matchInfo);
     Debug.Log("OnMatchCreate");
     currentMatchID = (System.UInt64)matchInfo.networkId;
     currentNodeID  = (System.UInt64)matchInfo.nodeId;
 }
        public void OnCreateMatch(CreateMatchResponse response)
        {
            this.response = response;

            if (this.response.success)
            {
                this.networkManager.OnMatchCreate(response);
                this.nextState = new InGameHostState(this.networkManager, this.networkMatch);
            }
        }
Example #7
0
    private void CreateMatchCallBack(CreateMatchResponse response)
    {
        UnityEngine.Debug.Log("New game created");

        var match = response.Match;

        CurrentGame.MatchId    = match.MatchId;
        CurrentGame.MatchState = match.State;
        SaveMatchId(match.MatchId);
        OnNewMatchCreated(CurrentGame);
    }
Example #8
0
    private void OnMatchCreate(CreateMatchResponse matchResponse)
    {
        isHost         = true;
        this.networkId = matchResponse.networkId;
        this.nodeId    = matchResponse.nodeId;

        if (matchResponse.success)
        {
            NetManager.singleton.OnMatchCreate(matchResponse);
        }
    }
Example #9
0
 public void OnMatchCreate(CreateMatchResponse aMatchResponse)
 {
     if (aMatchResponse.success)
     {
         NetworkManager.singleton.OnMatchCreate(aMatchResponse);
     }
     else
     {
         Debug.LogError("Create match failed");
     }
 }
Example #10
0
    public override void OnMatchCreate(CreateMatchResponse matchInfo)
    {
        if (matchInfo.success)
        {
            base.OnMatchCreate(matchInfo);

            GameObject gameManager = (GameObject)Instantiate(spawnPrefabs[0], Vector3.zero, Quaternion.identity);
            DontDestroyOnLoad(gameManager);
            NetworkServer.Spawn(gameManager);
            //Network.Instantiate(playerPrefab, Vector2.zero, Quaternion.identity, 0);
        }
    }
Example #11
0
 public void OnMatchCreate(CreateMatchResponse matchResponse)
 {
     if (matchResponse.success)
     {
         Debug.Log("Create match succeeded");
         matchCreated = true;
         Utility.SetAccessTokenForNetwork(matchResponse.networkId, new NetworkAccessToken(matchResponse.accessTokenString));
         NetworkServer.Listen(new MatchInfo(matchResponse), 9000);
     }
     else
     {
         Debug.LogError("Create match failed");
     }
 }
Example #12
0
 /// <summary>
 /// 创建房间后的回调函数
 /// </summary>
 /// <param name="response">
 /// 包含已创建的房间的信息
 /// </param>
 private void _OnCreateMatch (CreateMatchResponse response)
 {
     if (response.success)
     {
         Utility.SetAccessTokenForNetwork(response.networkId, new NetworkAccessToken(response.accessTokenString));
         client = StartHost(new MatchInfo(response));
         m_netStt = ConstantDefine.NetworkState.Host;
     }
     else
     {
         m_waitingPanel.SetActive(false);
         _Error("FAILED TO CREATE A ROOM");
     }
 }
Example #13
0
    public void OnMatchCreate(CreateMatchResponse matchResponse)
    {
        if (matchResponse.success)
        {
            successObject.SetActive(true);
            Utility.SetAccessTokenForNetwork(matchResponse.networkId, new NetworkAccessToken(matchResponse.accessTokenString));

            NetworkClient nc = nm.StartHost(new MatchInfo(matchResponse));
            nc.RegisterHandler(MsgType.Connect, OnConnected);
        }
        else
        {
            print("Match create error!");
        }
    }
Example #14
0
 /// <summary>
 /// Triggered after the creation of a Match
 /// </summary>
 /// <param name="matchResponse">Response from the Network to the match creation (Used here to test sucess)</param>
 public virtual void OnMatchCreate(CreateMatchResponse matchResponse)
 {
     if (matchResponse.success)
     {
         Debug.Log("OnMatchCreate > Success");
         SwitchSelectedMap();
         networkOverlord.StartHost(); //Host a game with current map in networkManager
     }
     else
     {
         Debug.LogError("OnMatchCreate > Failure, please verify internet connection");
         SwitchSelectedMap();
         networkOverlord.StartHost(); //Host a game with current map in networkManager
     }
 }
Example #15
0
 public virtual void OnMatchCreate(CreateMatchResponse matchInfo)
 {
     if (LogFilter.logDebug)
     {
         Debug.Log("NetworkManager OnMatchCreate " + matchInfo);
     }
     if (matchInfo.success)
     {
         Utility.SetAccessTokenForNetwork(matchInfo.networkId, new NetworkAccessToken(matchInfo.accessTokenString));
         StartHost(new MatchInfo(matchInfo));
     }
     else if (LogFilter.logError)
     {
         Debug.LogError("Create Failed:" + matchInfo);
     }
 }
Example #16
0
 /// <summary>
 /// 创建房间后的回调函数
 /// </summary>
 /// <param name="response">
 /// 包含已创建的房间的信息
 /// </param>
 private void _OnCreateMatch(CreateMatchResponse response)
 {
     MatchUI.instance.StopWait();
     if (response.success)
     {
         //令牌
         Utility.SetAccessTokenForNetwork(response.networkId, new NetworkAccessToken(response.accessTokenString));
         //创建后立即进入房间
         client         = StartHost(new MatchInfo(response));
         m_networkState = ConstantDefine.NetworkState.Host;
     }
     else
     {
         //处理错误
     }
 }
Example #17
0
 private void onMatchCreate(CreateMatchResponse matchResponse)
 {
     if (matchResponse.success)
     {
         Debug.Log("Creates match");
         Utility.SetAccessTokenForNetwork(matchResponse.networkId, new UnityEngine.Networking.Types.NetworkAccessToken(matchResponse.accessTokenString));
         FindObjectOfType <CustomLobbyManager>().StartHost(new MatchInfo(matchResponse));
         _matchCreated = true;
         readyButton.gameObject.SetActive(true);
         playerList.transform.parent.gameObject.SetActive(true);
     }
     else
     {
         joinButton.gameObject.SetActive(true);
         hostButton.gameObject.SetActive(true);
         Debug.LogError("Failed to create match");
     }
 }
Example #18
0
    public virtual void createRoomCallback(CreateMatchResponse resp)
    {
        Debug.Log("Room creation was successful: " + resp.success);
        if (resp.success)
        {
            //ideally we could continue to refresh and sit in the lobby here, but unity apparently will not allow us to create a game and not join it immediately.
            doRefreshNow();
            doRefresh = false;
            OnMatchCreate(resp);            //this will join immediately, which may be what we want once testing is done
            ServerChangeScene(onlineScene); //is this necessary??
            Debug.Log("Joined");

            Debug.Log("Scene switched");
        }
        else
        {
            doRefreshNow();
        }
    }
Example #19
0
    public void OnMatchCreate(CreateMatchResponse matchResponse)
    {
        if (matchResponse.success)
        {
            Debug.Log("Create match succeeded");
            Utility.SetAccessTokenForNetwork(matchResponse.networkId,
                                             new NetworkAccessToken(matchResponse.accessTokenString));

            m_MatchCreated = true;
            m_MatchInfo    = new MatchInfo(matchResponse);

            StartServer(matchResponse.address, matchResponse.port, matchResponse.networkId,
                        matchResponse.nodeId);
        }
        else
        {
            Debug.LogError("Create match failed");
        }
    }
Example #20
0
 private void OnCreateMatch(CreateMatchResponse res)
 {
     if (res != null && res.success)
     {
         //_networkManger.OnMatchCreate(res);
         GameObject obj = GameObject.Find("RoomsUI");
         if (obj != null)
         {
             obj.SetActive(false);
         }
         res.port = 7000;
         Debug.Log("Create match succeeded Port: " + res.port);
         MatchInfo hostInfo = new MatchInfo(res);
         NetworkServer.Listen(hostInfo, 9000);
         Debug.Log("Host Port: " + hostInfo.port);
         _networkManger.StartHost(hostInfo);
     }
     else
     {
         Debug.LogError("Create match failed");
     }
 }
Example #21
0
    public void OnMatchCreate(CreateMatchResponse matchResponse)
    {
        if (matchResponse.success)
        {
            connectionStatus = "Match named " + matchName + " created. Waiting for another player to join...";

            joinPanel.FindChild("Image").GetComponent <Image>().color = new Color(0f, 0f, 0f, 0f);
            createMatchButton.gameObject.SetActive(false);
            joinMatchButton.gameObject.SetActive(false);
            backButton.gameObject.SetActive(true);

            matchCreated = true;
            Utility.SetAccessTokenForNetwork(matchResponse.networkId, new NetworkAccessToken(matchResponse.accessTokenString));
            matchInfo = new MatchInfo(matchResponse);
            NetworkServer.Listen(matchInfo, 7777);
            NetworkServer.RegisterHandler(MsgType.Connect, OnPlayerReadyMessage);
        }
        else
        {
            Debug.LogError("Create match failed");
        }
    }
Example #22
0
 public override void OnMatchCreate(CreateMatchResponse matchInfo)
 {
     base.OnMatchCreate(matchInfo);
     MatchCreate.Invoke(matchInfo);
 }
Example #23
0
 public override void OnMatchCreate(CreateMatchResponse matchInfo)
 {
     Log("OnMatchCreate");
     base.OnMatchCreate(matchInfo);
 }
Example #24
0
 public override void OnMatchCreate(CreateMatchResponse matchInfo)
 {
     base.OnMatchCreate(matchInfo);
     _currentMatchID = (ulong)matchInfo.networkId;
 }