SetOnlineStatus









How do I use Set Online Status
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: ChatGui.cs Copy
215     private void GuiSendsMsg()
216     {
217         if (string.IsNullOrEmpty(this.inputLine))
218         {
219
220             GUI.FocusControl("");
221             return;
222         }
223
224         if (this.inputLine[0].Equals('\\'))
225         {
226             string[] tokens = this.inputLine.Split(new char[] {' '}, 2);
227             if (tokens[0].Equals("\\help"))
228             {
229                 this.PostHelpToCurrentChannel();
230             }
231             if (tokens[0].Equals("\\state"))
232             {
233                 int newState = int.Parse(tokens[1]);
234                 this.chatClient.SetOnlineStatus(newState, new string[] { "i am state " + newState }); // this is how you set your own state and (any) message
235             }
236             else if (tokens[0].Equals("\\subscribe") && !string.IsNullOrEmpty(tokens[1]))
237             {
238                 this.chatClient.Subscribe(tokens[1].Split(new char[] {' ', ','}));
239             }
240             else if (tokens[0].Equals("\\unsubscribe") && !string.IsNullOrEmpty(tokens[1]))
241             {
242                 this.chatClient.Unsubscribe(tokens[1].Split(new char[] {' ', ','}));
243             }
244             else if (tokens[0].Equals("\\clear"))
245             {
246                 if (this.doingPrivateChat)
247                 {
248                     this.chatClient.PrivateChannels.Remove(this.selectedChannelName);
249                 }
250                 else
251                 {
252                     ChatChannel channel;
253                     if (this.chatClient.TryGetChannel(this.selectedChannelName, this.doingPrivateChat, out channel))
254                     {
255                         channel.ClearMessages();
256                     }
257                 }
258             }
259             else if (tokens[0].Equals("\\msg") && !string.IsNullOrEmpty(tokens[1]))
260             {
261                 string[] subtokens = tokens[1].Split(new char[] {' ', ','}, 2);
262                 string targetUser = subtokens[0];
263                 string message = subtokens[1];
264                 this.chatClient.SendPrivateMessage(targetUser, message);
265             }
266         }
267         else
268         {
269             if (this.doingPrivateChat)
270             {
271                 this.chatClient.SendPrivateMessage(this.userIdInput, this.inputLine);
272             }
273             else
274             {
275                 this.chatClient.PublishMessage(this.selectedChannelName, this.inputLine);
276             }
277         }
278
279         this.inputLine = "";
280         GUI.FocusControl("");
281     }
File name: ChatGui.cs Copy
296     public void OnConnected()
297     {
298         if (this.ChannelsToJoinOnConnect != null && this.ChannelsToJoinOnConnect.Length > 0)
299         {
300             this.chatClient.Subscribe(this.ChannelsToJoinOnConnect, this.HistoryLengthToFetch);
301         }
302
303         this.chatClient.AddFriends(new string[] {"tobi", "ilya"}); // Add some users to the server-list to get their status updates
304         this.chatClient.SetOnlineStatus(ChatUserStatus.Online); // You can set your online state (without a mesage).
305     }
File name: ChatClient.cs Copy
343         /// The message object can be anything that Photon can serialize, including (but not limited to)
350         private bool SetOnlineStatus(int status, object message, bool skipMessage)
351         {
352             if (!this.CanChat)
353             {
354                 // TODO: log error
355                 return false;
356             }
357
358             Dictionary parameters = new Dictionary
359                 {
360                     { ChatParameterCode.Status, status },
361                 };
362
363             if (skipMessage)
364             {
365                 parameters[ChatParameterCode.SkipMessage] = true;
366             }
367             else
368             {
369                 parameters[ChatParameterCode.Message] = message;
370             }
371             return this.chatPeer.OpCustom(ChatOperationCode.UpdateStatus, parameters, true);
372         }
File name: ChatClient.cs Copy
386         public bool SetOnlineStatus(int status)
387         {
388             return SetOnlineStatus(status, null, true);
389         }
File name: ChatClient.cs Copy
398         /// The message object can be anything that Photon can serialize, including (but not limited to)
404         public bool SetOnlineStatus(int status, object message)
405         {
406             return SetOnlineStatus(status, message, false);
407         }

SetOnlineStatus 137 lượt xem

Gõ tìm kiếm nhanh...