OnSubscribed









How do I use On Subscribed
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: ChatGui.cs Copy
317     public void OnSubscribed(string[] channels, bool[] results)
318     {
319
320         // this demo can automatically send a "hi" to subscribed channels. in a game you usually only send user's input!!
321         if (this.DemoPublishOnSubscribe)
322         {
323             foreach (string channel in channels)
324             {
325                 this.chatClient.PublishMessage(channel, "says 'hi' in OnSubscribed(). "); // you don't HAVE to send a msg on join but you could.
326             }
327         }
328     }
File name: ChatClient.cs Copy
735         private void HandleSubscribeEvent(EventData eventData)
736         {
737             var channelsInResponse = (string[])eventData.Parameters[ChatParameterCode.Channels];
738             var results = (bool[])eventData.Parameters[ChatParameterCode.SubscribeResults];
739
740             for (int i = 0; i < channelsInResponse.Length; i++)
741             {
742                 if (results[i])
743                 {
744                     string channelName = channelsInResponse[i];
745                     if (!this.PublicChannels.ContainsKey(channelName))
746                     {
747                         ChatChannel channel = new ChatChannel(channelName);
748                         this.PublicChannels.Add(channel.Name, channel);
749                     }
750                 }
751             }
752
753             this.listener.OnSubscribed(channelsInResponse, results);
754         }

OnSubscribed 131 lượt xem

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