예제 #1
0
        public static PNStatus CreatePNStatus(PNStatusCategory category, string errorString, Exception errorException, bool error, PNOperationType operation, ChannelEntity channelEntity, RequestState pnRequestState, PubNubUnity pnUnity)
        {
            PNErrorData errorData = null;

            if ((!string.IsNullOrEmpty(errorString)) || (errorException != null))
            {
                errorData      = new PNErrorData();
                errorData.Info = errorString;
                errorData.Ex   = errorException;
            }
            List <string> affectedChannels      = null;
            List <string> affectedChannelGroups = null;

            if (channelEntity.ChannelID.IsChannelGroup)
            {
                affectedChannelGroups = new List <string>();
                affectedChannelGroups.Add(channelEntity.ChannelID.ChannelOrChannelGroupName);
            }
            else
            {
                affectedChannels = new List <string>();
                affectedChannels.Add(channelEntity.ChannelID.ChannelOrChannelGroupName);
            }

            return(CreatePNStatus(category, errorData, error, operation, affectedChannels, affectedChannelGroups, pnRequestState, pnUnity));
        }
예제 #2
0
        public static PNStatus CreatePNStatus(PNStatusCategory category, string errorString, Exception errorException, bool error, PNOperationType operation, List <ChannelEntity> affectedChannels, List <ChannelEntity> affectedChannelGroups, RequestState pnRequestState, PubNubUnity pnUnity)
        {
            PNErrorData errorData = CreateErrorData(errorString, errorException);

            List <string> channels      = CreateListOfStringFromListOfChannelEntity(affectedChannels);
            List <string> channelGroups = CreateListOfStringFromListOfChannelEntity(affectedChannelGroups);

            return(CreatePNStatus(category, errorData, error, operation, channels, channelGroups, pnRequestState, pnUnity));
        }
예제 #3
0
        internal static PNStatus CreatePNStatus(PNStatusCategory category, PNErrorData errorData, bool error, PNOperationType operation, List <string> channels, List <string> channelGroups, RequestState pnRequestState, PubNubUnity pnUnity)
        {
            long   statusCode = 0;
            string url        = "";

            if (pnRequestState != null)
            {
                statusCode = pnRequestState.ResponseCode;
                url        = pnRequestState.URL;
            }

            PNStatus pnStatus = new PNStatus(
                category,
                errorData,
                error,
                statusCode,
                operation,
                pnUnity.PNConfig.Secure,
                pnUnity.PNConfig.UUID,
                pnUnity.PNConfig.AuthKey,
                pnUnity.PNConfig.Origin,
                channels,
                channelGroups,
                url
                );

            #if (ENABLE_PUBNUB_LOGGING)
            pnUnity.PNLog.WriteToLog(string.Format("CreatePNStatus: \n" +
                                                   "category={0} \n" +
                                                   "errorData={1} \n" +
                                                   "error={2} \n" +
                                                   "statusCode={3} \n" +
                                                   "operation={4} \n" +
                                                   "tlsEnabled={5} \n" +
                                                   "uuid={6} \n" +
                                                   "authKey={7} \n" +
                                                   "origin={8} \n" +
                                                   "channels={9} \n" +
                                                   "channelGroups={10} \n" +
                                                   "clientRequest={11} \n",
                                                   category.ToString(),
                                                   ((errorData != null) && (errorData.Ex != null)) ? errorData.Ex.ToString() : "null",
                                                   error.ToString(),
                                                   statusCode.ToString(),
                                                   operation.ToString(),
                                                   pnUnity.PNConfig.Secure,
                                                   pnUnity.PNConfig.UUID,
                                                   pnUnity.PNConfig.AuthKey,
                                                   pnUnity.PNConfig.Origin,
                                                   (channels != null) ? string.Join(",", channels.ToArray()) : "null",
                                                   (channelGroups != null) ? string.Join(",", channelGroups.ToArray()) : "null",
                                                   url
                                                   ), PNLoggingMethod.LevelInfo);
            #endif

            return(pnStatus);
        }
예제 #4
0
        internal static PNErrorData CreateErrorData(string errorString, Exception errorException)
        {
            PNErrorData errorData = null;

            if ((!string.IsNullOrEmpty(errorString)) || (errorException != null))
            {
                errorData      = new PNErrorData();
                errorData.Info = errorString;
                errorData.Ex   = errorException;
            }
            return(errorData);
        }
예제 #5
0
 public PNStatus(PNStatusCategory category, PNErrorData errorData, bool error, long statusCode, PNOperationType operation, bool tlsEnabled, string uuid, string authKey, string origin, List <String> affectedChannels, List <String> affectedChannelGroups, object clientRequest)
 {
     this.Category              = category;
     this.ErrorData             = errorData;
     this.Error                 = error;
     this.StatusCode            = statusCode;
     this.Operation             = operation;
     this.TlsEnabled            = tlsEnabled;
     this.UUID                  = uuid;
     this.AuthKey               = authKey;
     this.Origin                = origin;
     this.ClientRequest         = clientRequest;
     this.AffectedChannelGroups = affectedChannelGroups;
     this.AffectedChannels      = affectedChannels;
 }