public SparkMatch(MatchFoundMessage message) { portID = message.Port.Value; hostURL = message.Host; acccessToken = message.AccessToken; matchID = message.MatchId; }
/// <summary> /// Sends the event match found. /// </summary> /// <param name="message">Message.</param> public void SendEvent_MatchFound(MatchFoundMessage message) { foreach (SparkBehaviour behaviour in ObservedBehaviours) { behaviour.Call("OnMatchFound", message); } }
void MatchFound(MatchFoundMessage message) { session_info = new RTSessionInfo(message); ManagersController.Message(Message.Create(this, MessageData.EVENT_SET_ONLINE_PLAYERS, session_info.players)); #region Create Session session = this.gameObject.GetComponent <GameSparksRTUnity> (); GSRequestData mockedResponse = new GSRequestData() .AddNumber("port", session_info.PortID) .AddString("host", session_info.HostURL) .AddString("accessToken", session_info.AccessToken); FindMatchResponse response = new FindMatchResponse(mockedResponse); session.Configure( response, peerID => OnPlayerConnected(peerID), peerID => OnPlayerDisconnected(peerID), ready => OnRTReady(ready), packet => OnPacketRecieved(packet) ); session.Connect(); #endregion }
private void OnMatchFound(MatchFoundMessage obj) { Debug.Log("OnMatchFound"); _rtSessionInfo = new RTSessionInfo(obj); GameSparksManager.Instance().StartNewRtSession(_rtSessionInfo); //SceneManager.LoadScene("GamePlay"); }
public NetworkSessionInfo(MatchFoundMessage message) { _matchFoundMessage = message; _matchId = message.MatchId; _hostUrl = message.Host; _accessToken = message.AccessToken; if (message.Port != null) { _portId = message.Port.Value; } else { Debug.LogError("GameSparks doesent has portId!"); } foreach (var participant in message.Participants) { if (participant.PeerId != null) { var player = new NetworkPlayer(participant); if (player.GamesparksId == GameSparksManager.Instance().GameSparksId) { _player = player; } _playerList.Add(player); } else { Debug.LogError("GameSparks doesnt has peerId!"); } } }
void OnMatchFound(MatchFoundMessage message) { m_txtSearch.gameObject.SetActive(false); m_gameSparksManager .CurrentMultiplayerSession = new RTSessionInfo(message); }
/// <summary> /// Raises the match found event. /// </summary> /// <param name="message">Message.</param> private void OnMatchFound(MatchFoundMessage message) { foreach (SparkView view in sparkViews) { view.SendEvent_MatchFound(message); } }
public RtSession(MatchFoundMessage message) { HostUrl = message.Host; MatchId = message.MatchId; PortId = message.Port ?? 0; AccessToken = message.AccessToken; _toString = CreateToString(message); }
private void OnMatchFound(MatchFoundMessage m) { var s = new RtSession(m); foreach (var l in _onMatchFoundListeners) { l(s); } }
public void onMatchFound(MatchFoundMessage matchFoundMessage) { addToConsole("---Matchmaking with id " + matchFoundMessage.requestId + " and challenge id " + matchFoundMessage.realtimeChallengeId + " found"); connectToRealtimeServer = new ConnectToRealtimeServer(matchFoundMessage.address, CONNECTIVITY_ID, access_token, matchFoundMessage.realtimeChallengeId, tConsole); connectToRealtimeServer.init(); }
private void OnMatchFound(MatchFoundMessage message) { Debug.Log("On match found."); status = "Match found! Trying to join..."; playerNames = message.Participants.Select(x => x.DisplayName).ToArray(); SparkManager.instance.StartMatch(message); }
public virtual void OnMatchFoundInvoke(MatchFoundMessage x) { if (GameSparksManager.Instance().IsDebug) { var subs = OnMatchFound?.GetInvocationList(); var debugStr = "OnMatchFound InvokationList: "; subs?.ToList().ForEach(m => debugStr += "\n" + m.Method.Name); Debug.Log(debugStr); } OnMatchFound?.Invoke(x); }
public RTSessionInfo(MatchFoundMessage _message) { portID = (int)_message.Port; hostURL = _message.Host; acccessToken = _message.AccessToken; matchID = _message.MatchId; foreach (MatchFoundMessage._Participant p in _message.Participants) { playerList.Add(new RTPlayer(p.DisplayName, p.Id, (int)p.PeerId)); } }
public RTSessionInfo(MatchFoundMessage message) { m_port = (int)message.Port; m_hostUrl = message.Host; m_accessToken = message.AccessToken; m_matchID = message.MatchId; foreach (var p in message.Participants) { m_playerList.Add(new RTPlayer(p.Id, (int)p.PeerId)); } }
//============================= public RTSessionInfo(MatchFoundMessage message) { _portID = (int)message.Port; _hostURL = message.Host; _accessToken = message.AccessToken; _matchID = message.MatchId; foreach (MatchFoundMessage._Participant p in message.Participants) { _players.Add(new RTPlayer(p.DisplayName, p.Id, (int)p.PeerId)); } }
public MatchInfo(MatchFoundMessage _message) { portID = (int)_message.Port; hostURL = _message.Host; acccessToken = _message.AccessToken; matchID = _message.MatchId; // we loop through each participant and get their peerId and display name // foreach (MatchFoundMessage._Participant p in _message.Participants) { playerList.Add(new Player(p.DisplayName, p.Id, (int)p.PeerId)); } }
private void MatchFound(MatchFoundMessage obj) { //RoomOptions roomOptions = new RoomOptions(); //roomOptions.MaxPlayers = (byte)maxplayers; //roomOptions.EmptyRoomTtl = 0; //PhotonNetwork.JoinOrCreateRoom(obj.MatchId, roomOptions, TypedLobby.Default); print("Room Name: " + obj.MatchId); PhotonNetwork.JoinOrCreateRoom(obj.MatchId, new RoomOptions() { MaxPlayers = (byte)2, IsVisible = false, EmptyRoomTtl = 0 }, TypedLobby.Default); }
/// <summary> /// Updates the real time session information based upon the match found message generated when a match is found /// </summary> /// <param name="_message">information about the match found</param> public RTSessionInfo(MatchFoundMessage _message) { m_PortID = (int)_message.Port; m_HostURL = _message.Host; m_AccessToken = _message.AccessToken; m_MatchID = _message.MatchId; //Loop through each participant and get their peerId and display name: foreach (MatchFoundMessage._Participant p in _message.Participants) { m_PlayerList.Add(new RTPlayer(p.DisplayName, p.Id, (int)p.PeerId)); } }
private void OnMatchFoundMessage(MatchFoundMessage msg) { players.Clear(); players.AddRange(msg.Participants.Where(p => p.PeerId != null).Select(p => new PlayerInfo { DisplaName = p.DisplayName, Id = p.Id, Peer = (int)p.PeerId, OnLine = true })); RTSession.Configure(msg, OnPlayerConnect, OnPlayerDisconnect, OnReady, OnRTPacket); lobbyManager.UpdatePlayersCount(players.Count); StartCoroutine(StartSession()); }
/// <summary> /// Creates a new RTSessionInfo object which is held until a new RT session is created /// </summary> /// <param name="message">Message.</param> public RTSessionInfo(MatchFoundMessage message, string userId) { m_portId = (int)message.Port; m_hostUrl = message.Host; m_acccessToken = message.AccessToken; m_matchId = message.MatchId; // we loop through each participant and get their peerId and display name // foreach (MatchFoundMessage._Participant p in message.Participants) { bool isMe = p.Id == userId; m_playerList.Add(new RtPlayer(p.DisplayName, p.Id, (int)p.PeerId, isMe)); } }
private void StartNewSession(RTSessionInfo sessionInfo, MatchFoundMessage resp) { Debug.Log("GSM| Creating New RT Session Instance..."); RtGS = gameObject.AddComponent <GameSparksRTUnity>(); RtGS.Configure(resp, (peerId) => { OnPlayerConnectedToGame(peerId); }, (peerId) => { OnPlayerDisconnected(peerId); }, (ready) => { OnRTReady(ready); }, (packet) => { OnPacketReceived(packet); } ); RtGS.Connect(); }
public void GetMatchFoundMessage(MatchFoundMessage message) { Debug.Log("got match found message"); Debug.Log("The challenge Match found message :" + message.JSONString); log.text = "Match found"; //Debug.Log("1- The match found message is :"+message.Participants.ToString()); //Debug.Log("3- The match found message is :"+message.JSONData); //Debug.Log("4- The match found message is :"+message.JSONData.ToString()); //Debug.Log("5- The match found message is :"+message.ScriptData); //Debug.Log("The match found message is :"+message.ScriptData.GetString("matchShortCode")); }
private static string CreateToString(MatchFoundMessage m) { var s = new StringBuilder() .AppendLine($"Port: {m.Port}") .AppendLine($"Host URL: {m.Host}") .AppendLine("--- --- ---") .AppendLine($"MatchId: {m.MatchId}") .AppendLine($"Players: {m.Participants.Count()}"); foreach (var p in m.Participants) { s.AppendLine(CreatePlayer(p).ToString()); } s.AppendLine($"Access Token: {m.AccessToken}"); return(s.ToString()); }
public RTSessionInfo(MatchFoundMessage matchFoundMessage) { PortId = (int)matchFoundMessage.Port; HostUrl = matchFoundMessage.Host; AccessToken = matchFoundMessage.AccessToken; MatchId = matchFoundMessage.MatchId; RtPlayerList = new List <RTPlayer>(); foreach (MatchFoundMessage._Participant participant in matchFoundMessage.Participants) { RtPlayerList.Add(new RTPlayer( participant.DisplayName, participant.Id, (int)participant.PeerId)); } }
private static void OnMatchFound(MatchFoundMessage matchFoundMessage) { if (matchFoundMessage == null || matchFoundMessage.HasErrors) { Debug.Log("OnMatchFound received no valid match"); GameController.Instance.Lobby.OnSearchCancelled(); return; } List <LobbyPlayerModel> players = new List <LobbyPlayerModel>(); foreach (var participant in matchFoundMessage.Participants) { players.Add(new LobbyPlayerModel(participant.DisplayName, participant.Id, (int)participant.PeerId)); } GameController.Instance.Lobby.OnMatchFound(players, matchFoundMessage.Host, (int)matchFoundMessage.Port, matchFoundMessage.AccessToken, matchFoundMessage.MatchId); // Connect to found match immediately. GameSparksRTManager.Instance.StartNewRTSession(matchFoundMessage.Host, (int)matchFoundMessage.Port, matchFoundMessage.AccessToken, OnRTMatchConnected); }
public RtSession(MatchFoundMessage message) { HostUrl = message.Host; MatchId = message.MatchId; PlayerList = new List <RtPlayer>(); AccessToken = message.AccessToken; if (message.Port != null) { PortId = (int)message.Port; } foreach (var p in message.Participants) { if (p.PeerId != null) { PlayerList.Add(new RtPlayer(p.DisplayName, p.Id, (int)p.PeerId)); } } }
//Configure the SDK with a MatchFoundMessage public void Configure(MatchFoundMessage message, Action<int> OnPlayerConnect, Action<int> OnPlayerDisconnect, Action<bool> OnReady, Action<RTPacket> OnPacket) { if(!message.Port.HasValue){ Debug.Log("Response does not contain a port, exiting."); return; } Configure(message.Host, message.Port.Value, message.AccessToken, OnPlayerConnect, OnPlayerDisconnect, OnReady, OnPacket); }
/// <summary> /// Starts the match. /// </summary> /// <param name="message">Message.</param> public void StartMatch(MatchFoundMessage message) { sparkMatch = new SparkMatch(message); foreach (MatchFoundMessage._Participant participant in message.Participants) { SparkPeer peer = new SparkPeer(participant.DisplayName, participant.Id, participant.PeerId.Value); sparkMatch.peerList.Add(peer); } sparkNetwork.Configure(message, OnPlayerConnect, OnPlayerDisconnect, OnReady, OnPacket ); sparkNetwork.Connect(); }
//Configure the SDK with a MatchFoundMessage public void Configure(MatchFoundMessage message, Action <int> OnPlayerConnect, Action <int> OnPlayerDisconnect, Action <bool> OnReady, Action <RTPacket> OnPacket) { if (!message.Port.HasValue) { Debug.Log("Response does not contain a port, exiting."); return; } Configure(message.Host, message.Port.Value, message.AccessToken, OnPlayerConnect, OnPlayerDisconnect, OnReady, OnPacket); }
private void OnMatchFound(MatchFoundMessage message) { Debug.Log("Match Found!..."); StringBuilder sBuilder = new StringBuilder(); sBuilder.AppendLine("Match Found..."); sBuilder.AppendLine("Host URL:" + message.Host); sBuilder.AppendLine("Port:" + message.Port); sBuilder.AppendLine("Access Token:" + message.AccessToken); sBuilder.AppendLine("MatchId:" + message.MatchId); sBuilder.AppendLine("Opponents:" + message.Participants.Count()); sBuilder.AppendLine("_________________"); sBuilder.AppendLine(); // we'll leave a space between the player-list and the match data foreach (MatchFoundMessage._Participant player in message.Participants) { sBuilder.AppendLine("Player:" + player.PeerId + " User Name:" + player.DisplayName); // add the player number and the display name to the list } m_playerList.text = sBuilder.ToString(); // set the string to be the player-list field m_rtSessionInfo = new RTSessionInfo(message, GS.GSPlatform.UserId); ToggleStartMatch(true); }
private void OnMatchFound(MatchFoundMessage resp) { Debug.Log(resp.JSONString); bool assigned = false; foreach (var participant in resp.Participants) { if (participant.Id == UserId) { PeerId = (int)participant.PeerId; if (!assigned) { IsHost = true; assigned = true; } } } sessionInfo = new RTSessionInfo(resp); StartNewSession(sessionInfo, resp); }