public void SendGo() { var powerModel = new PubNubPowerModel(); powerModel.event_type = "go"; powerModel.device_id = mDeviceId; SendMsgTo_FromClientChannel(powerModel); }
public void SendReady(string count) { var powerModel = new PubNubPowerModel(); powerModel.event_type = "ready"; powerModel.device_id = mDeviceId; //? powerModel.player_id = mPlayerId; powerModel.team_id = "shipRace_team_1"; powerModel.name = count; SendMsgTo_FromClientChannel(powerModel); }
public void SendGoal(string thisname) { var powerModel = new PubNubPowerModel(); powerModel.event_type = "goal"; powerModel.device_id = mDeviceId; //? powerModel.player_id = mPlayerId; powerModel.team_id = "shipRace_team_1"; powerModel.name = thisname; SendMsgTo_FromClientChannel(powerModel); }
public void UpdateTimer(string time) { var powerModel = new PubNubPowerModel(); powerModel.event_type = "update_timer"; powerModel.device_id = mDeviceId; //? powerModel.player_id = mPlayerId; powerModel.team_id = "shipRace_team_1"; powerModel.name = time; SendMsgTo_FromClientChannel(powerModel); }
public void SendResults(string name, string score) { var powerModel = new PubNubPowerModel(); powerModel.event_type = "results"; powerModel.device_id = ""; //? powerModel.player_id = score; powerModel.team_id = ""; powerModel.name = name; SendMsgTo_FromClientChannel(powerModel); }
public void AddScoreCallback(string name, string devID, string score) { var powerModel = new PubNubPowerModel(); powerModel.event_type = "add_score_callback"; powerModel.device_id = devID; //? powerModel.player_id = score; powerModel.team_id = ""; powerModel.name = name; SendMsgTo_FromClientChannel(powerModel); }
private void PubnubFromClientSubscribeReturnMessage(string result) { Debug.Log("PubnubFromClientSubscribeReturnMessage: " + result); if (!string.IsNullOrEmpty(result) && !string.IsNullOrEmpty(result.Trim())) { List <object> deserializedMessage = mPubnubInitialize.JsonPluggableLibrary.DeserializeToListOfObject(result); if (deserializedMessage != null && deserializedMessage.Count > 0) { object subscribedObject = (object)deserializedMessage [0]; if (subscribedObject != null) { //IF CUSTOM OBJECT IS EXCEPTED, YOU CAN CAST THIS OBJECT TO YOUR CUSTOM CLASS TYPE string resultActualMessage = mPubnubInitialize.JsonPluggableLibrary.SerializeToJsonString(subscribedObject); Debug.Log(resultActualMessage); PubNubPowerModel powerModel = new PubNubPowerModel(); JsonUtility.FromJsonOverwrite(resultActualMessage, powerModel); // Debug.Log(powerModel.team_id); if (powerModel.event_type.Equals("name_set") && Server) { WinAppMenu.Instance.AddPlayer(powerModel.name, powerModel.device_id); } else if (powerModel.event_type.Equals("goal") && Server) { WinAppMenu.Instance.AddScore(powerModel.name, powerModel.device_id); } else if (powerModel.event_type.Equals("update_timer") && !Server) { MenuStateController.Instance.SetTimerVal(int.Parse(powerModel.name)); } else if (powerModel.event_type.Equals("ready") && !Server) { MenuStateController.Instance.SetReady(powerModel.name); } else if (powerModel.event_type.Equals("go") && !Server) { MenuStateController.Instance.SetGo(); } else if (powerModel.event_type.Equals("add_score_callback") && !Server) { MenuStateController.Instance.SetScore(powerModel.name, powerModel.player_id); } else if (powerModel.event_type.Equals("results") && !Server) { MenuStateController.Instance.SetResults(powerModel.name, powerModel.player_id); } } } } }
private void PubnubToClientSubscribeReturnMessage(string result) { UnityEngine.Debug.Log(result); if (!string.IsNullOrEmpty(result) && !string.IsNullOrEmpty(result.Trim())) { List <object> deserializedMessage = mPubnubToClient.JsonPluggableLibrary.DeserializeToListOfObject(result); if (deserializedMessage != null && deserializedMessage.Count > 0) { object subscribedObject = (object)deserializedMessage [0]; if (subscribedObject != null) { string resultActualMessage = mPubnubInitialize.JsonPluggableLibrary.SerializeToJsonString(subscribedObject); var moveModel = new PubNubMoveModel(); var powerModel = new PubNubPowerModel(); JsonUtility.FromJsonOverwrite(resultActualMessage, powerModel); JsonUtility.FromJsonOverwrite(resultActualMessage, moveModel); UnityEngine.Debug.Log(moveModel.event_type + "work!!!"); if (!powerModel.event_type.Equals("name_set")) { return; } if (powerModel.team_id.Equals("shipRace_team_1")) { Debug.Log(powerModel.name); } if (moveModel.team_id.Equals("shipRace_team_2")) { } if (moveModel.team_id.Equals("shipRace_team_3")) { } } } } }