void SusbcribeCallbackHandler2(object sender, EventArgs e) { SusbcribeEventEventArgs mea = e as SusbcribeEventEventArgs; if (mea.Status != null) { switch (mea.Status.Category) { case PNStatusCategory.PNUnexpectedDisconnectCategory: case PNStatusCategory.PNTimeoutCategory: break; } } if (mea.MessageResult != null) { Debug.Log("SusbcribeCallback in message" + mea.MessageResult.Channel + mea.MessageResult.Payload); Dictionary <string, object> messageIds = mea.MessageResult.Payload as Dictionary <string, object>; UnityEngine.Debug.Log("message_id:" + messageIds["message_id"]); DisplayMessages(messageIds, mea.MessageResult.Channel); } if (mea.PresenceEventResult != null) { Debug.Log("SusbcribeCallback in presence" + mea.PresenceEventResult.Channel + mea.PresenceEventResult.Occupancy + mea.PresenceEventResult.Event); } }
private void MessageListener(object sender, EventArgs e) { SusbcribeEventEventArgs mea = e as SusbcribeEventEventArgs; if (mea.Status != null) { if (debug) { PubnubStatusCategoryLogger(mea.Status.Category); } if (mea.Status.Error) { if (debug) { Debug.LogError(displayName + mea.Status.ErrorData.Info); } RaiseHandleMessage(true, null, handleMessageCallback, mea.Status.ErrorData.Ex); } } if (mea.MessageResult != null) { Dictionary <string, object> msg = mea.MessageResult.Payload as Dictionary <string, object>; if (debug) { Debug.Log(displayName + "New message!"); } lastMessageTimestamp = mea.MessageResult.Timetoken + 1; RaiseHandleMessage(false, msg, handleMessageCallback); } }
// call back private static void Callback(object sender, EventArgs e) { SusbcribeEventEventArgs messageEvent = e as SusbcribeEventEventArgs; if (messageEvent == null) { return; } if (messageEvent.MessageResult == null) { return; } Debug.Log("message received"); Dictionary <string, object> message = messageEvent.MessageResult.Payload as Dictionary <string, object>; if (message == null) { return; } if (messageEvent.MessageResult.Channel.Equals("route-to-fire")) { Path.Clear(); foreach (string road in (string[])message["path"]) { Debug.Log(road); WaypointPath roadWp = GameObject.Find(road).GetComponent <WaypointPath>(); Path.Add(roadWp); } IsSomethingOnFire = true; UpdatePath(); } }
// Start is called before the first frame update void Start() { // Use this for initialization PNConfiguration pnConfiguration = new PNConfiguration(); pnConfiguration.PublishKey = "pub-c-36e8fff3-a450-4b43-98be-5a14f10c69b4"; pnConfiguration.SubscribeKey = "sub-c-68d3c0d8-9b58-11e9-9ac8-0ed882abeb26"; pnConfiguration.LogVerbosity = PNLogVerbosity.BODY; pnConfiguration.UUID = Random.Range(0f, 999999f).ToString(); PubNubConnection.pubnub = new PubNub(pnConfiguration); Debug.Log(pnConfiguration.UUID); MyClass myFireObject = new MyClass(); myFireObject.test = "new user"; string fireobject = JsonUtility.ToJson(myFireObject); PubNubConnection.pubnub.Fire() .Channel("my_channel") .Message(fireobject) .Async((result, status) => { if (status.Error) { Debug.Log(status.Error); Debug.Log(status.ErrorData.Info); } else { Debug.Log(string.Format("Fire Timetoken: {0}", result.Timetoken)); } }); PubNubConnection.pubnub.SusbcribeCallback += (sender, e) => { SusbcribeEventEventArgs mea = e as SusbcribeEventEventArgs; if (mea.Status != null) { } if (mea.MessageResult != null) { Dictionary <string, object> msg = mea.MessageResult.Payload as Dictionary <string, object>; string[] scores = msg["score"] as string[]; print(scores[0]); GetHighScore.highScore = int.Parse(scores[0]); } if (mea.PresenceEventResult != null) { Debug.Log("In Example, SusbcribeCallback in presence" + mea.PresenceEventResult.Channel + mea.PresenceEventResult.Occupancy + mea.PresenceEventResult.Event); } }; PubNubConnection.pubnub.Subscribe() .Channels(new List <string> () { "my_channel2" }) .WithPresence() .Execute(); }
// Use this for initialization void Start() { // Use this for initialization PNConfiguration pnConfiguration = new PNConfiguration(); pnConfiguration.PublishKey = "pub-c-efb4a8fe-605a-42e8-866a-facc7271a49d"; pnConfiguration.SubscribeKey = "sub-c-1bb9d4ac-52f4-11e8-85c6-a6b0a876dba1"; pnConfiguration.LogVerbosity = PNLogVerbosity.BODY; //pnConfiguration.UUID = Random.Range (0f, 999999f).ToString (); inputResponse = GameObject.Find("InputObject").GetComponent <InputScript>().UUIDinput.ToString(); Debug.Log(inputResponse); pnConfiguration.UUID = inputResponse; pubnub = new PubNub(pnConfiguration); Debug.Log(pnConfiguration.UUID); UUIDText.text = "UUID: " + pnConfiguration.UUID; pubnub.SusbcribeCallback += (sender, e) => { SusbcribeEventEventArgs mea = e as SusbcribeEventEventArgs; if (mea.Status != null) { } if (mea.MessageResult != null) { lastClickText.text = "Last Publish Sent by: " + mea.MessageResult.IssuingClientId.ToString(); if ((int)mea.MessageResult.Payload == 1) { CubeObject.GetComponent <Renderer>().material = Pepe; } if ((int)mea.MessageResult.Payload == 2) { CubeObject.GetComponent <Renderer>().material = Pepe2; } if ((int)mea.MessageResult.Payload == 3) { CubeObject.GetComponent <Renderer>().material = Pepe3; } } if (mea.PresenceEventResult != null) { //lastClickText.text = mea.PresenceEventResult.UUID.ToString(); Debug.Log("In Example, SusbcribeCallback in presence" + mea.PresenceEventResult.Channel + mea.PresenceEventResult.Occupancy + mea.PresenceEventResult.Event); } }; pubnub.Subscribe() .Channels(new List <string> () { "my_channel" }) .WithPresence() .Execute(); }
private Vector3 _heading; // Where the user looking. void Start() { MLEyes.Start(); // Start eye tracking. MLInput.Start(); // Start input controller. MLInput.OnTriggerDown += HandleOnTriggerDown; // Get trigger down event. meshRenderer = gameObject.GetComponent <MeshRenderer>(); // Get the game object. PNConfiguration pnConfiguration = new PNConfiguration(); // Start PubNub pnConfiguration.PublishKey = "pub-c-bb13912e-7007-46ce-a954-74fe4c6cb131"; // YOUR PUBLISH KEY HERE. pnConfiguration.SubscribeKey = "sub-c-e14cda48-b857-11e8-b27d-1678d61e8f93"; // YOUR SUBSCRIBE KEY HERE. pubnub = new PubNub(pnConfiguration); pn_uuid = pnConfiguration.UUID; // Get the UUID of the PubNub client. pubnub.Subscribe() .Channels(new List <string>() { meshRenderer.name // Subscribe to the channel for the game object. }) .Execute(); pubnub.SusbcribeCallback += (sender, e) => { SusbcribeEventEventArgs message = e as SusbcribeEventEventArgs; if (message.Status != null) { switch (message.Status.Category) { case PNStatusCategory.PNUnexpectedDisconnectCategory: case PNStatusCategory.PNTimeoutCategory: pubnub.Reconnect(); break; } } if (message.MessageResult != null) { // Does the message equal the UUID for this client? if (message.MessageResult.Payload.ToString() == pn_uuid) // Message and client UUID are the same. { meshRenderer.material = OwnedMaterial; // The user owns the game object, change material to OwnedMaterial to show. looking = false; owned = true; } else // Message and client UUID are NOT the same. { if (owned) // Only need to change color if the user owns the game object. { meshRenderer.material = NonFocusedMaterial; // Another user has taken the game object, change material to NonFocusedMaterial to show.. owned = false; } } } }; }
void Start() { //This section establishes the parameters for connecting to Pubnub PNConfiguration connectionSettings = new PNConfiguration(); connectionSettings.PublishKey = pubKey; connectionSettings.SubscribeKey = subKey; connectionSettings.LogVerbosity = PNLogVerbosity.BODY; connectionSettings.Secure = true; //////// dataServer = new PubNub(connectionSettings); //make the connection to the server Debug.Log("Connected to Pubnub"); //Subscribe to the channel specified above dataServer.Subscribe() .Channels(new List <string>() { channelName }) .Execute(); //define the function that is called when a new message arrives //unlike javascript it is named and defined all at once rather than linking to another function dataServer.SusbcribeCallback += (sender, evt) => { SusbcribeEventEventArgs inMessage = evt as SusbcribeEventEventArgs; if (inMessage.MessageResult != null) //error check to insure the message has contents { //convert the object that holds the message contents into a Dictionary Dictionary <string, object> msg = inMessage.MessageResult.Payload as Dictionary <string, object>; Debug.Log(inMessage.MessageResult.Payload); Debug.Log("GOOOO!!!"); // //trainSpeed = (float)msg["trainS"]; //force convert the "slide" parameter of the dictionary to be an integer and assign it to the currentSlide variable. trainSpeed = (int)msg["train"]; //force convert the "slide" parameter of the dictionary to be an integer and assign it to the currentSlide variable. } }; }
public void Onsubscribe() { pubnub.SusbcribeCallback += (sender, e) => { SusbcribeEventEventArgs mea = e as SusbcribeEventEventArgs; if (mea.Status != null) { log.text = "called mea.status"; } if (mea.MessageResult != null) { log.text = "called mea.status"; Debug.Log("Entered in Mea.Subscribe"); Dictionary <string, object> msg = mea.MessageResult.Payload as Dictionary <string, object>; string[] strArr = msg["username"] as string[]; string[] strScores = msg["score"] as string[]; int usernamevar = 1; foreach (string username in strArr) { string usernameobject = "Line" + usernamevar; GameObject.Find(usernameobject).GetComponent <Text>().text = usernamevar.ToString() + ". " + username.ToString(); usernamevar++; Debug.Log(username); log.text = "username: "******""; } int scorevar = 1; foreach (string score in strScores) { string scoreobject = "Score" + scorevar; GameObject.Find(scoreobject).GetComponent <Text>().text = "Score: " + score.ToString(); scorevar++; Debug.Log(score); log.text = "score: " + score + ""; } } if (mea.PresenceEventResult != null) { Debug.Log("In Example, SusbcribeCallback in presence" + mea.PresenceEventResult.Channel + mea.PresenceEventResult.Occupancy + mea.PresenceEventResult.Event); } }; pubnub.Subscribe() .Channels(new List <string>() { "LEaderBoardchannel" }) .WithPresence() .Execute(); }
void Start() { videoPlayer.SetActive(false); PNConfiguration connectionSettings = new PNConfiguration(); connectionSettings.PublishKey = pubKey; connectionSettings.SubscribeKey = subKey; connectionSettings.LogVerbosity = PNLogVerbosity.BODY; connectionSettings.Secure = true; //////// dataServer = new PubNub(connectionSettings); Debug.Log("Connected to Pubnub"); dataServer.Subscribe() .Channels(new List <string>() { channelName }) .Execute(); //// when message arrives:///////// dataServer.SusbcribeCallback += (sender, evt) => { SusbcribeEventEventArgs inMessage = evt as SusbcribeEventEventArgs; if (inMessage.MessageResult != null) { Dictionary <string, object> msg = inMessage.MessageResult.Payload as Dictionary <string, object>; inVote = (int)msg["totalHits"]; if (inVote > currentVote) { videoPlayer.SetActive(true); currentVote = inVote; } } }; }
void SusbcribeCallbackHandler(object sender, EventArgs e) { SusbcribeEventEventArgs mea = e as SusbcribeEventEventArgs; if (mea.Status != null) { switch (mea.Status.Category) { case PNStatusCategory.PNConnectedCategory: PrintStatus(mea.Status); pubnub.Publish().Channel("my_channel").Message("Hello from the PubNub Unity SDK").Ttl(10).UsePost(true).Async((result, status) => { if (!status.Error) { Debug.Log(string.Format("DateTime {0}, In Publish Example, Timetoken: {1}", DateTime.UtcNow, result.Timetoken)); } else { Debug.Log(status.Error); Debug.Log(status.ErrorData.Info); } }); break; case PNStatusCategory.PNUnexpectedDisconnectCategory: case PNStatusCategory.PNTimeoutCategory: pubnub.Reconnect(); pubnub.CleanUp(); break; } } if (mea.MessageResult != null) { Debug.Log("In Example, SusbcribeCallback in message" + mea.MessageResult.Channel + mea.MessageResult.Payload); Display(string.Format("SusbcribeCallback Result: {0}", pubnub.JsonLibrary.SerializeToJsonString(mea.MessageResult.Payload))); } if (mea.PresenceEventResult != null) { Debug.Log("In Example, SusbcribeCallback in presence" + mea.PresenceEventResult.Channel + mea.PresenceEventResult.Occupancy + mea.PresenceEventResult.Event); } }
//public Object[] tiles = {} // Use this for initialization void Start() { Button btn = SubmitButton.GetComponent <Button>(); btn.onClick.AddListener(TaskOnClick); // Use this for initialization PNConfiguration pnConfiguration = new PNConfiguration(); pnConfiguration.PublishKey = "pub-c-87790afb-caa1-41c1-954d-37ccbd86682c"; pnConfiguration.SubscribeKey = "sub-c-7b4a7626-a628-11eb-96f4-7e87b170c68c"; //Publish Key: pub - c - 87790afb - caa1 - 41c1 - 954d - 37ccbd86682c //Subscribe Key: sub - c - 7b4a7626 - a628 - 11eb - 96f4 - 7e87b170c68c pnConfiguration.LogVerbosity = PNLogVerbosity.BODY; pnConfiguration.UUID = Random.Range(0f, 999999f).ToString(); pubnub = new PubNub(pnConfiguration); Debug.Log(pnConfiguration.UUID); MyClass myFireObject = new MyClass(); myFireObject.test = "new user"; string fireobject = JsonUtility.ToJson(myFireObject); pubnub.Fire() .Channel("submit_score") .Message(fireobject) .Async((result, status) => { if (status.Error) { Debug.Log(status.Error); Debug.Log(status.ErrorData.Info); } else { Debug.Log(string.Format("Fire Timetoken: {0}", result.Timetoken)); } }); pubnub.SusbcribeCallback += (sender, e) => { SusbcribeEventEventArgs mea = e as SusbcribeEventEventArgs; if (mea.Status != null) { } if (mea.MessageResult != null) { Dictionary <string, object> msg = mea.MessageResult.Payload as Dictionary <string, object>; string[] strArr = msg["username"] as string[]; string[] strScores = msg["score"] as string[]; int usernamevar = 1; foreach (string username in strArr) { string usernameobject = "Line" + usernamevar; GameObject.Find(usernameobject).GetComponent <Text>().text = usernamevar.ToString() + ". " + username.ToString(); usernamevar++; Debug.Log(username); } int scorevar = 1; foreach (string score in strScores) { string scoreobject = "Score" + scorevar; GameObject.Find(scoreobject).GetComponent <Text>().text = "Score: " + score.ToString(); scorevar++; Debug.Log(score); } } if (mea.PresenceEventResult != null) { Debug.Log("In Example, SusbcribeCallback in presence" + mea.PresenceEventResult.Channel + mea.PresenceEventResult.Occupancy + mea.PresenceEventResult.Event); } }; pubnub.Subscribe() .Channels(new List <string>() { "leaderboard_scores" }) .WithPresence() .Execute(); }
//public InputField FieldUsername; //public InputField FieldScore; //public Object[] tiles = {} // Use this for initialization void Start() { //Button btn = SubmitButton.GetComponent<Button>(); //btn.onClick.AddListener(TaskOnClick); // Use this for initialization PNConfiguration pnConfiguration = new PNConfiguration(); pnConfiguration.PublishKey = "pub-c-552fdd0f-5c19-4557-baa4-1f8c2263b4ed"; pnConfiguration.SubscribeKey = "sub-c-b55b4074-8312-11e9-84b9-2e401b25e788"; pnConfiguration.LogVerbosity = PNLogVerbosity.BODY; pnConfiguration.UUID = Random.Range(0f, 999999f).ToString(); pubnub = new PubNub(pnConfiguration); Debug.Log(pnConfiguration.UUID); MyClass myFireObject = new MyClass(); myFireObject.test = "Player 1"; string fireobject = JsonUtility.ToJson(myFireObject); pubnub.Fire() .Channel("beach_cg_channel") .Message(fireobject) .Async((result, status) => { if (status.Error) { Debug.Log(status.Error); Debug.Log(status.ErrorData.Info); } else { Debug.Log(string.Format("Fire Timetoken: {0}", result.Timetoken)); } }); pubnub.SusbcribeCallback += (sender, e) => { SusbcribeEventEventArgs mea = e as SusbcribeEventEventArgs; if (mea.Status != null) { } if (mea.MessageResult != null) { Dictionary <string, object> msg = mea.MessageResult.Payload as Dictionary <string, object>; string[] strArr = msg["username"] as string[]; string[] strScores = msg["score"] as string[]; int usernamevar = 1; foreach (string username in strArr) { string usernameobject = "Line" + usernamevar; GameObject.Find(usernameobject).GetComponent <Text>().text = usernamevar.ToString() + ". " + username.ToString(); usernamevar++; Debug.Log(username); } int scorevar = 1; foreach (string score in strScores) { string scoreobject = "Score" + scorevar; GameObject.Find(scoreobject).GetComponent <Text>().text = "Score: " + score.ToString(); scorevar++; Debug.Log(score); } } if (mea.PresenceEventResult != null) { Debug.Log("In Example, SusbcribeCallback in presence" + mea.PresenceEventResult.Channel + mea.PresenceEventResult.Occupancy + mea.PresenceEventResult.Event); } }; pubnub.Subscribe() .Channels(new List <string> () { "beach_cg_channel" }) .WithPresence() .Execute(); }
// Use this for initialization void Start() { Debug.Log(PlayerPrefs.GetString("EMAIL")); Debug.Log(PlayerPrefs.GetInt("Score")); publishKey = "pub-c-ed03b041-dbd1-4421-af39-404baa9fdcce"; subscribeKey = "sub-c-22588262-e977-11e8-8495-720743810c32"; Button btn = SubmitButton.GetComponent <Button>(); btn.onClick.AddListener(TaskOnClick); // Use this for initialization PNConfiguration pnConfiguration = new PNConfiguration(); pnConfiguration.PublishKey = publishKey; pnConfiguration.SubscribeKey = subscribeKey; pnConfiguration.LogVerbosity = PNLogVerbosity.BODY; pnConfiguration.UUID = Random.Range(0f, 999999f).ToString(); pubnub = new PubNub(pnConfiguration); Debug.Log(pnConfiguration.UUID); MyClass myFireObject = new MyClass(); myFireObject.test = "new user"; string fireobject = JsonUtility.ToJson(myFireObject); pubnub.Fire() .Channel("LEaderBoardchannel") .Message(fireobject) .Async((result, status) => { if (status.Error) { Debug.Log(status.Error); Debug.Log(status.ErrorData.Info); log.text = status.Error.ToString(); } else { Debug.Log(string.Format("Fire Timetoken: {0}", result.Timetoken)); log.text = string.Format("Fire Timetoken: {0}", result.Timetoken); } }); pubnub.SusbcribeCallback += (sender, e) => { SusbcribeEventEventArgs mea = e as SusbcribeEventEventArgs; if (mea.Status != null) { log.text = "called mea.status"; } if (mea.MessageResult != null) { log.text = "called mea.status"; Debug.Log("Entered in Mea.Subscribe"); Dictionary <string, object> msg = mea.MessageResult.Payload as Dictionary <string, object>; string[] strArr = msg["username"] as string[]; string[] strScores = msg["score"] as string[]; int usernamevar = 1; foreach (string username in strArr) { string usernameobject = "Line" + usernamevar; GameObject.Find(usernameobject).GetComponent <Text>().text = usernamevar.ToString() + ". " + username.ToString(); usernamevar++; Debug.Log(username); log.text = "username: "******""; } int scorevar = 1; foreach (string score in strScores) { string scoreobject = "Score" + scorevar; GameObject.Find(scoreobject).GetComponent <Text>().text = "Score: " + score.ToString(); scorevar++; Debug.Log(score); log.text = "score: " + score + ""; } } if (mea.PresenceEventResult != null) { Debug.Log("In Example, SusbcribeCallback in presence" + mea.PresenceEventResult.Channel + mea.PresenceEventResult.Occupancy + mea.PresenceEventResult.Event); } }; pubnub.Subscribe() .Channels(new List <string>() { "LEaderBoardchannel" }) .WithPresence() .Execute(); }
// Use this for initialization void Start() { Button btn = SubmitButton.GetComponent <Button> (); btn.onClick.AddListener(TaskOnClick); // Use this for initialization PNConfiguration pnConfiguration = new PNConfiguration(); pnConfiguration.PublishKey = "pub-c-36e8fff3-a450-4b43-98be-5a14f10c69b4"; pnConfiguration.SubscribeKey = "sub-c-68d3c0d8-9b58-11e9-9ac8-0ed882abeb26"; pnConfiguration.LogVerbosity = PNLogVerbosity.BODY; pnConfiguration.UUID = Random.Range(0f, 999999f).ToString(); pubnub = new PubNub(pnConfiguration); Debug.Log(pnConfiguration.UUID); MyClass myFireObject = new MyClass(); myFireObject.test = "new user"; string fireobject = JsonUtility.ToJson(myFireObject); pubnub.Fire() .Channel("my_channel") .Message(fireobject) .Async((result, status) => { if (status.Error) { Debug.Log(status.Error); Debug.Log(status.ErrorData.Info); } else { Debug.Log(string.Format("Fire Timetoken: {0}", result.Timetoken)); } }); pubnub.SusbcribeCallback += (sender, e) => { SusbcribeEventEventArgs mea = e as SusbcribeEventEventArgs; if (mea.Status != null) { } if (mea.MessageResult != null) { Dictionary <string, object> msg = mea.MessageResult.Payload as Dictionary <string, object>; string[] strArr = msg["username"] as string[]; string[] strScores = msg["score"] as string[]; string[] strTimes = msg["time"] as string[]; for (int i = 0; i < names.Length; i++) { names[i].text = strArr[i]; scores[i].text = strScores[i]; times[i].text = strTimes[i]; } // Hide submit stuff if score not high enough if (ScoreCounter.Score <= int.Parse(strScores[4])) { HighScoreFields.SetActive(false); } } if (mea.PresenceEventResult != null) { Debug.Log("In Example, SusbcribeCallback in presence" + mea.PresenceEventResult.Channel + mea.PresenceEventResult.Occupancy + mea.PresenceEventResult.Event); } }; pubnub.Subscribe() .Channels(new List <string> () { "my_channel2" }) .WithPresence() .Execute(); }
void Start() { // Use this for initialization PNConfiguration pnConfiguration = new PNConfiguration(); pnConfiguration.PublishKey = "<PUT-HERE-THE-PUBNUB-PUBLISH-KEY>"; pnConfiguration.SubscribeKey = "<PUT-HERE-THE-PUBNUB-SUBSCRIBE-KEY>"; pnConfiguration.LogVerbosity = PNLogVerbosity.BODY; pnConfiguration.UUID = Random.Range(0f, 999999f).ToString(); pubnub = new PubNub(pnConfiguration); Debug.Log(pnConfiguration.UUID); MyClass myFireObject = new MyClass(); myFireObject.test = "Player 1"; string fireobject = JsonUtility.ToJson(myFireObject); pubnub.Fire() .Channel("beach_cg_channel") .Message(fireobject) .Async((result, status) => { if (status.Error) { Debug.Log(status.Error); Debug.Log(status.ErrorData.Info); } else { Debug.Log(string.Format("Fire Timetoken: {0}", result.Timetoken)); } }); pubnub.SusbcribeCallback += (sender, e) => { SusbcribeEventEventArgs mea = e as SusbcribeEventEventArgs; if (mea.Status != null) { } if (mea.MessageResult != null) { Dictionary <string, object> msg = mea.MessageResult.Payload as Dictionary <string, object>; string[] strArr = msg["username"] as string[]; string[] strScores = msg["score"] as string[]; int usernamevar = 1; foreach (string username in strArr) { string usernameobject = "Line" + usernamevar; GameObject.Find(usernameobject).GetComponent <Text>().text = usernamevar.ToString() + ". " + username.ToString(); usernamevar++; Debug.Log(username); } int scorevar = 1; foreach (string score in strScores) { string scoreobject = "Score" + scorevar; GameObject.Find(scoreobject).GetComponent <Text>().text = "Score: " + score.ToString(); scorevar++; Debug.Log(score); } } if (mea.PresenceEventResult != null) { Debug.Log("In Example, SusbcribeCallback in presence" + mea.PresenceEventResult.Channel + mea.PresenceEventResult.Occupancy + mea.PresenceEventResult.Event); } }; pubnub.Subscribe() .Channels(new List <string> () { "beach_cg_channel" }) .WithPresence() .Execute(); }