public static ChannelEntity CreateChannelEntity(string channelOrChannelGroupName2, bool isAwaitingConnectCallback, bool isChannelGroup, Dictionary <string, object> userState, PNLoggingMethod pnLog) { string channelOrChannelGroupName = channelOrChannelGroupName2.Trim(); #if (ENABLE_PUBNUB_LOGGING) pnLog.WriteToLog(string.Format("CreateChannelEntity: channelOrChannelGroupName {0}, {1}", channelOrChannelGroupName.ToString(), channelOrChannelGroupName2.ToString()), PNLoggingMethod.LevelInfo); #endif if (!string.IsNullOrEmpty(channelOrChannelGroupName)) { ChannelIdentity ci = new ChannelIdentity(); ci.ChannelOrChannelGroupName = channelOrChannelGroupName; ci.IsPresenceChannel = Utility.IsPresenceChannel(channelOrChannelGroupName); ci.IsChannelGroup = isChannelGroup; ChannelParameters cp = new ChannelParameters(); cp.IsAwaitingConnectCallback = isAwaitingConnectCallback; cp.UserState = userState; ChannelEntity ce = new ChannelEntity(ci, cp); return(ce); } else { #if (ENABLE_PUBNUB_LOGGING) pnLog.WriteToLog(string.Format("CreateChannelEntity: channelOrChannelGroupName empty, is channel group {0}", isChannelGroup.ToString()), PNLoggingMethod.LevelInfo); #endif return(null); } }
public ChannelEntity(ChannelIdentity channelID, ChannelParameters channelParams) { this.ChannelID = channelID; this.ChannelParams = channelParams; }
internal void ResponseToUserCallbackForSubscribe(List <SubscribeMessage> subscribeMessages) { #if (ENABLE_PUBNUB_LOGGING) this.PubNubInstance.PNLog.WriteToLog(string.Format("In ResponseToUserCallbackForSubscribeV2"), PNLoggingMethod.LevelInfo); #endif if (subscribeMessages.Count >= this.PubNubInstance.PNConfig.MessageQueueOverflowCount) { PNStatus pnStatus = Helpers.CreatePNStatus( PNStatusCategory.PNRequestMessageCountExceededCategory, "", null, true, PNOperationType.PNSubscribeOperation, PubNubInstance.SubscriptionInstance.AllChannels, PubNubInstance.SubscriptionInstance.AllChannelGroups, null, this.PubNubInstance ); CreateEventArgsAndRaiseEvent(pnStatus); } foreach (SubscribeMessage subscribeMessage in subscribeMessages) { #if (ENABLE_PUBNUB_LOGGING) this.PubNubInstance.PNLog.WriteToLog(string.Format("ResponseToUserCallbackForSubscribeV2:\n SubscribeMessage:\n" + "shard : {0},\n" + "subscriptionMatch: {1},\n" + "channel: {2},\n" + "payload: {3},\n" + "flags: {4},\n" + "issuingClientId: {5},\n" + "subscribeKey: {6},\n" + "sequenceNumber: {7},\n" + "originatingTimetoken tt: {8},\n" + "originatingTimetoken region: {9},\n" + "publishMetadata tt: {10},\n" + "publishMetadata region: {11},\n" + "userMetadata {12} \n", subscribeMessage.Shard, subscribeMessage.SubscriptionMatch, subscribeMessage.Channel, subscribeMessage.Payload.ToString(), subscribeMessage.Flags, subscribeMessage.IssuingClientId, subscribeMessage.SubscribeKey, subscribeMessage.SequenceNumber, (subscribeMessage.OriginatingTimetoken != null) ? subscribeMessage.OriginatingTimetoken.Timetoken.ToString() : "", (subscribeMessage.OriginatingTimetoken != null) ? subscribeMessage.OriginatingTimetoken.Region : "", (subscribeMessage.PublishTimetokenMetadata != null) ? subscribeMessage.PublishTimetokenMetadata.Timetoken.ToString() : "", (subscribeMessage.PublishTimetokenMetadata != null) ? subscribeMessage.PublishTimetokenMetadata.Region : "", (subscribeMessage.UserMetadata != null) ? subscribeMessage.UserMetadata.ToString() : "null"), PNLoggingMethod.LevelInfo); #endif bool isPresenceChannel = Utility.IsPresenceChannel(subscribeMessage.Channel); if (string.IsNullOrEmpty(subscribeMessage.SubscriptionMatch) || subscribeMessage.Channel.Equals(subscribeMessage.SubscriptionMatch)) { //channel ChannelIdentity ci = new ChannelIdentity(subscribeMessage.Channel, false, isPresenceChannel); FindChannelEntityAndCallback(subscribeMessage, ci); } else if (subscribeMessage.SubscriptionMatch.Contains(".*") && isPresenceChannel) { //wildcard presence channel ChannelIdentity ci = new ChannelIdentity(subscribeMessage.SubscriptionMatch, false, false); FindChannelEntityAndCallback(subscribeMessage, ci); } else if (subscribeMessage.SubscriptionMatch.Contains(".*")) { //wildcard channel ChannelIdentity ci = new ChannelIdentity(subscribeMessage.SubscriptionMatch, false, isPresenceChannel); FindChannelEntityAndCallback(subscribeMessage, ci); } else { ChannelIdentity ci = new ChannelIdentity(subscribeMessage.SubscriptionMatch, true, isPresenceChannel); FindChannelEntityAndCallback(subscribeMessage, ci); //ce will be the cg and subscriptionMatch will have the cg name } } }
internal void FindChannelEntityAndCallback(SubscribeMessage subscribeMessage, ChannelIdentity ci) { bool isPresenceChannel = Utility.IsPresenceChannel(subscribeMessage.Channel); PNStatus pns = new PNStatus(); pns.Error = false; SubscribeEventEventArgs mea = new SubscribeEventEventArgs(); mea.Status = pns; if (((subscribeMessage.SubscriptionMatch.Contains(".*")) && isPresenceChannel) || (isPresenceChannel)) { #if (ENABLE_PUBNUB_LOGGING) this.PubNubInstance.PNLog.WriteToLog("Raising presence message event ", PNLoggingMethod.LevelInfo); #endif PNPresenceEventResult subMessageResult; CreatePNPresenceEventResult(subscribeMessage, out subMessageResult); mea.PresenceEventResult = subMessageResult; PubNubInstance.RaiseEvent(mea); } else { PNMessageResult subMessageResult; CreatePNMessageResult(subscribeMessage, out subMessageResult); #if (ENABLE_PUBNUB_LOGGING) this.PubNubInstance.PNLog.WriteToLog("Raising message event ", PNLoggingMethod.LevelInfo); #endif if (!string.IsNullOrEmpty(this.PubNubInstance.PNConfig.CipherKey) && (this.PubNubInstance.PNConfig.CipherKey.Length > 0)) { subMessageResult.Payload = Helpers.DecodeMessage(PubNubInstance.PNConfig.CipherKey, subMessageResult.Payload, PNOperationType.PNSubscribeOperation, this.PubNubInstance); } mea.MessageResult = subMessageResult; PubNubInstance.RaiseEvent(mea); } }