Beispiel #1
0
        public void TestBuildWhereNowRequestCommon(bool ssl, string authKey, string sessionUUID)
        {
            string uuid = "customuuid";

            Pubnub pubnub = new Pubnub(
                Common.PublishKey,
                Common.SubscribeKey,
                "",
                "",
                ssl
                );

            pubnub.AuthenticationKey = authKey;
            string authKeyString = "";

            if (!string.IsNullOrEmpty(authKey))
            {
                authKeyString = string.Format("&auth={0}", pubnub.AuthenticationKey);
            }

            Uri uri = BuildRequests.BuildWhereNowRequest(uuid, sessionUUID,
                                                         ssl, pubnub.Origin, pubnub.AuthenticationKey, Common.SubscribeKey
                                                         );

            //http://ps.pndsn.com/v2/presence/sub_key/demo-36/uuid/customuuid?uuid=&auth=authKey&pnsdk=PubNub-CSharp-UnityIOS/3.6.9.0
            string expected = string.Format("http{0}://{1}/v2/presence/sub_key/{2}/uuid/{3}?uuid={4}{5}&pnsdk={6}",
                                            ssl?"s":"", pubnub.Origin, Common.SubscribeKey, uuid, sessionUUID,
                                            authKeyString,
                                            Utility.EncodeUricomponent(PubnubUnity.Version, ResponseType.WhereNow, false, false)
                                            );
            string received = uri.OriginalString;

            Common.LogAndCompare(expected, received);
        }
Beispiel #2
0
        public void TestBuildPresenceHeartbeatRequestCommon(string[] channels, string userState,
                                                            bool ssl, string authKey)
        {
            string uuid = "customuuid";

            Pubnub pubnub = new Pubnub(
                Common.PublishKey,
                Common.SubscribeKey,
                "",
                "",
                ssl
                );

            pubnub.AuthenticationKey = authKey;
            string authKeyString = "";

            if (!string.IsNullOrEmpty(authKey))
            {
                authKeyString = string.Format("&auth={0}", pubnub.AuthenticationKey);
            }

            Uri uri = BuildRequests.BuildPresenceHeartbeatRequest(channels, userState, uuid, ssl,
                                                                  pubnub.Origin, pubnub.AuthenticationKey, Common.SubscribeKey
                                                                  );

            //https://pubsub.pubnub.com/v2/presence/sub_key/demo-36/channel/user_state_channel/heartbeat?uuid=customuuid&state={"k":"v"}&auth=authKey&pnsdk=PubNub-CSharp-UnityIOS/3.6.9.0

            string expected = string.Format("http{0}://{1}/v2/presence/sub_key/{2}/channel/{3}/heartbeat?uuid={4}{5}{6}{7}&pnsdk={8}",
                                            ssl?"s":"", pubnub.Origin, Common.SubscribeKey, string.Join(",", channels), uuid, (userState == "")?"":"&state=", userState,
                                            authKeyString, PubnubUnity.Version
                                            );
            string received = uri.ToString();

            Common.LogAndCompare(expected, received);
        }
        public void TestBuildGlobalHereNowRequestCommon(bool ssl, bool showUUIDList, bool includeUserState, string authKey){
            string uuid = "customuuid";

            Pubnub pubnub = new Pubnub (
                Common.PublishKey,
                Common.SubscribeKey,
                "",
                "",
                ssl
            );
            pubnub.AuthenticationKey = authKey;
            string authKeyString = "";
            if (!string.IsNullOrEmpty(authKey)) {
                authKeyString = string.Format ("&auth={0}", pubnub.AuthenticationKey);
            }

            int disableUUID = (showUUIDList) ? 0 : 1;
            int userState = (includeUserState) ? 1 : 0;
            string parameters = string.Format ("disable_uuids={0}&state={1}", disableUUID, userState);

            Uri uri = BuildRequests.BuildGlobalHereNowRequest (showUUIDList, includeUserState,
                uuid, ssl, pubnub.Origin, pubnub.AuthenticationKey, Common.SubscribeKey
            );

            //http://pubsub.pubnub.com/v2/presence/sub_key/demo-36?disable_uuids=1&state=0&uuid=customuuid&auth=authKey&pnsdk=PubNub-CSharp-UnityOSX/3.6.9.0
            string expected = string.Format ("http{0}://{1}/v2/presence/sub_key/{2}?{3}&uuid={4}{5}&pnsdk={6}",
                ssl?"s":"", pubnub.Origin, Common.SubscribeKey, parameters,
                uuid, authKeyString, 
                Utility.EncodeUricomponent(PubnubUnity.Version, ResponseType.GlobalHereNow, false, false)
            );
            string received = uri.OriginalString;
            Common.LogAndCompare (expected, received);
        }
Beispiel #4
0
        public void TestBuildGetUserStateRequestCommon(bool ssl, string authKey)
        {
            string channel   = "user_state_channel";
            string userState = "{\"k\":\"v\"}";
            string uuid      = "customuuid";

            Pubnub pubnub = new Pubnub(
                Common.PublishKey,
                Common.SubscribeKey,
                "",
                "",
                ssl
                );

            pubnub.AuthenticationKey = authKey;
            string authKeyString = "";

            if (!string.IsNullOrEmpty(authKey))
            {
                authKeyString = string.Format("&auth={0}", pubnub.AuthenticationKey);
            }

            Uri uri = BuildRequests.BuildGetUserStateRequest(channel, uuid, ssl,
                                                             pubnub.Origin, pubnub.AuthenticationKey, Common.SubscribeKey
                                                             );

            //https://pubsub.pubnub.com/v2/presence/sub_key/demo-36/channel/user_state_channel/uuid/customuuid?uuid=customuuid&auth=authKey&pnsdk=PubNub-CSharp-UnityIOS/3.6.9.0
            string expected = string.Format("http{0}://{1}/v2/presence/sub_key/{2}/channel/{3}/uuid/{4}?uuid={6}{7}&pnsdk={8}",
                                            ssl?"s":"", pubnub.Origin, Common.SubscribeKey, channel, uuid, userState,
                                            uuid, authKeyString, PubnubUnity.Version
                                            );
            string received = uri.ToString();

            Common.LogAndCompare(expected, received);
        }
Beispiel #5
0
        public void TestBuildLeaveRequestCommon(string[] channels, bool ssl, string authKey)
        {
            string uuid = "customuuid";

            Pubnub pubnub = new Pubnub(
                Common.PublishKey,
                Common.SubscribeKey,
                "",
                "",
                ssl
                );

            pubnub.AuthenticationKey = authKey;
            string authKeyString = "";

            if (!string.IsNullOrEmpty(authKey))
            {
                authKeyString = string.Format("&auth={0}", pubnub.AuthenticationKey);
            }

            Uri uri = BuildRequests.BuildMultiChannelLeaveRequest(channels, uuid, ssl,
                                                                  pubnub.Origin, pubnub.AuthenticationKey, Common.SubscribeKey
                                                                  );

            //https://pubsub.pubnub.com/v2/presence/sub_key/demo-36/channel/test/leave?uuid=customuuid&auth=authKey&pnsdk=PubNub-CSharp-UnityIOS/3.6.9.0
            string expected = string.Format("http{0}://{1}/v2/presence/sub_key/{2}/channel/{3}/leave?uuid={4}{5}&pnsdk={6}",
                                            ssl?"s":"", pubnub.Origin, Common.SubscribeKey, string.Join(",", channels),
                                            uuid, authKeyString, PubnubUnity.Version
                                            );
            string received = uri.ToString();

            Common.LogAndCompare(expected, received);
        }
Beispiel #6
0
        public void TestBuildSubscribeRequestCommon(string[] channels, object timetoken, string userState,
                                                    bool ssl, string authKey)
        {
            string uuid = "customuuid";

            Pubnub pubnub = new Pubnub(
                Common.PublishKey,
                Common.SubscribeKey,
                "",
                "",
                ssl
                );

            pubnub.AuthenticationKey = authKey;
            string authKeyString = "";

            if (!string.IsNullOrEmpty(authKey))
            {
                authKeyString = string.Format("&auth={0}", pubnub.AuthenticationKey);
            }

            Uri uri = BuildRequests.BuildMultiChannelSubscribeRequest(channels, timetoken, userState, uuid, ssl,
                                                                      pubnub.Origin, pubnub.AuthenticationKey, Common.SubscribeKey
                                                                      );

            //http://pubsub.pubnub.com/subscribe/demo-36/test/0/21221?uuid=customuuid&state={"k":"v"}&auth=authKey&pnsdk=PubNub-CSharp-UnityIOS/3.6.9.0
            string expected = string.Format("http{0}://{1}/subscribe/{2}/{3}/0/{4}?uuid={5}{6}{7}{8}&pnsdk={9}",
                                            ssl?"s":"", pubnub.Origin, Common.SubscribeKey, string.Join(",", channels), timetoken.ToString(),
                                            uuid, (userState == "")?"":"&state=", userState, authKeyString, PubnubUnity.Version
                                            );
            string received = uri.ToString();

            Common.LogAndCompare(expected, received);
        }
Beispiel #7
0
        public void TestBuildHereNowRequestCommon(bool testCh, bool testCg, bool ssl, bool showUUIDList, bool includeUserState, string authKey)
        {
            string channel         = "here_now_channel";
            string channelGroup    = "here_now_channelGroup";
            string channelGroupStr = string.Format("&channel-group={0}", Utility.EncodeUricomponent(channelGroup, ResponseType.HereNow, true, false));

            if (testCh && testCg)
            {
                // test both
            }
            else if (testCg)
            {
                channel = ",";
            }
            else
            {
                channelGroup    = "";
                channelGroupStr = "";
            }
            string uuid = "customuuid";

            Pubnub pubnub = new Pubnub(
                Common.PublishKey,
                Common.SubscribeKey,
                "",
                "",
                ssl
                );

            pubnub.AuthenticationKey = authKey;
            string authKeyString = "";

            if (!string.IsNullOrEmpty(authKey))
            {
                authKeyString = string.Format("&auth={0}", pubnub.AuthenticationKey);
            }

            int    disableUUID = (showUUIDList) ? 0 : 1;
            int    userState   = (includeUserState) ? 1 : 0;
            string parameters  = string.Format("disable_uuids={0}&state={1}", disableUUID, userState);

            Uri uri = BuildRequests.BuildHereNowRequest(channel, channelGroup, showUUIDList, includeUserState,
                                                        uuid, ssl, pubnub.Origin, pubnub.AuthenticationKey, Common.SubscribeKey
                                                        );

            //http://ps.pndsn.com/v2/presence/sub_key/demo-36/channel/here_now_channel?disable_uuids=1&state=0&uuid=customuuid&auth=authKey&pnsdk=PubNub-CSharp-UnityOSX/3.6.9.0
            string expected = string.Format("http{0}://{1}/v2/presence/sub_key/{2}/channel/{3}?{4}{8}&uuid={5}{6}&pnsdk={7}",
                                            ssl?"s":"", pubnub.Origin, Common.SubscribeKey, channel, parameters,
                                            uuid, authKeyString,
                                            Utility.EncodeUricomponent(PubnubUnity.Version, ResponseType.HereNow, false, true),
                                            channelGroupStr
                                            );
            string received = uri.OriginalString;

            Common.LogAndCompare(expected, received);
        }
        public void TestBuildDetailedHistoryRequestCommon(bool ssl, bool reverse, bool includeTimetoken,
                                                          string authKey, long startTime, long endTime, int count)
        {
            string channel = "history_channel";
            string uuid    = "customuuid";

            Pubnub pubnub = new Pubnub(
                Common.PublishKey,
                Common.SubscribeKey,
                "",
                "",
                ssl
                );

            pubnub.AuthenticationKey = authKey;
            string authKeyString = "";

            if (!string.IsNullOrEmpty(authKey))
            {
                authKeyString = string.Format("&auth={0}", pubnub.AuthenticationKey);
            }

            string startTimeString = "";
            string endTimeString   = "";

            if (startTime != -1)
            {
                startTimeString = string.Format("&start={0}", startTime.ToString());
            }
            if (endTime != -1)
            {
                endTimeString = string.Format("&end={0}", endTime.ToString());
            }


            Uri uri = BuildRequests.BuildDetailedHistoryRequest(channel, startTime, endTime, count, reverse,
                                                                includeTimetoken, uuid, ssl, pubnub.Origin, pubnub.AuthenticationKey, Common.SubscribeKey
                                                                );

            if (count == -1)
            {
                count = 100;
            }
            //Received:http://ps.pndsn.com/v2/history/sub-key/demo-36/channel/history_channel?count=90&reverse=true&start=14498416434364941&end=14498416799269095&auth=authKey&uuid=customuuid&pnsdk=PubNub-CSharp-UnityOSX/3.6.9.0
            //Received:https://ps.pndsn.com/v2/history/sub-key/demo-36/channel/history_channel?count=90&include_token=true&start=14498416434364941&end=14498416799269095&auth=authKey&uuid=customuuid&pnsdk=PubNub-CSharp-UnityOSX/3.6.9.0
            //http://ps.pndsn.com/v2/history/sub-key/demo-36/channel/publish_channel?count=90&start=14498416434364941&end=14498416799269095&auth=authKey&uuid=customuuid&pnsdk=PubNub-CSharp-UnityOSX/3.6.9.0
            string expected = string.Format("http{0}://{1}/v2/history/sub-key/{2}/channel/{3}?count={4}{5}{6}{7}{8}{9}&uuid={10}&pnsdk={11}",
                                            ssl?"s":"", pubnub.Origin, Common.SubscribeKey, channel, count,
                                            includeTimetoken?"&include_token=true":"", reverse?"&reverse=true":"",
                                            startTimeString, endTimeString, authKeyString, uuid,
                                            Utility.EncodeUricomponent(PubnubUnity.Version, ResponseType.DetailedHistory, false, true)
                                            );
            string received = uri.OriginalString;

            Common.LogAndCompare(expected, received);
        }
Beispiel #9
0
        public void TestBuildPublishRequestCommon(bool ssl, bool storeInHistory, string secretKey,
                                                  string cipherKey, string authKey)
        {
            string channel   = "publish_channel";
            string message   = "Test message";
            string uuid      = "customuuid";
            string signature = "0";
            Pubnub pubnub    = new Pubnub(
                Common.PublishKey,
                Common.SubscribeKey,
                secretKey,
                cipherKey,
                ssl
                );

            pubnub.AuthenticationKey = authKey;
            string authKeyString = "";

            if (!string.IsNullOrEmpty(authKey))
            {
                authKeyString = string.Format("&auth={0}", pubnub.AuthenticationKey);
            }
            string originalMessage = Helpers.JsonEncodePublishMsg(message, cipherKey, pubnub.JsonPluggableLibrary);

            if (secretKey.Length > 0)
            {
                StringBuilder stringToSign = new StringBuilder();
                stringToSign
                .Append(Common.PublishKey)
                .Append('/')
                .Append(Common.SubscribeKey)
                .Append('/')
                .Append(secretKey)
                .Append('/')
                .Append(channel)
                .Append('/')
                .Append(originalMessage);      // 1

                // Sign Message
                signature = Utility.Md5(stringToSign.ToString());
            }

            Uri uri = BuildRequests.BuildPublishRequest(channel, originalMessage, storeInHistory, uuid, ssl,
                                                        pubnub.Origin, pubnub.AuthenticationKey, Common.PublishKey, Common.SubscribeKey,
                                                        cipherKey, secretKey
                                                        );

            //http://pubsub.pubnub.com/publish/demo-36/demo-36/0/publish_channel/0?uuid=customuuid&auth=authKey&pnsdk=PubNub-CSharp-UnityOSX/3.6.9.0
            string expected = string.Format("http{0}://{1}/publish/{2}/{3}/{4}/{5}/0/{6}?uuid={7}{8}{9}&pnsdk={10}",
                                            ssl?"s":"", pubnub.Origin, Common.PublishKey, Common.SubscribeKey, signature, channel, originalMessage,
                                            uuid, storeInHistory?"":"&store=0", authKeyString, PubnubUnity.Version
                                            );
            string received = uri.ToString();

            Common.LogAndCompare(expected, received);
        }
Beispiel #10
0
        //remove channels
        //remove cg
        public void TestBuildRemoveChannelsFromChannelGroupRequestCommon(string[] channels, bool ssl, string authKey)
        {
            string channelGroup = "channelGroup";
            string uuid         = "customuuid";

            Pubnub pubnub = new Pubnub(
                Common.PublishKey,
                Common.SubscribeKey,
                "",
                "",
                ssl


                );

            pubnub.AuthenticationKey = authKey;
            string authKeyString = "";

            if (!string.IsNullOrEmpty(authKey))
            {
                authKeyString = string.Format("&auth={0}", pubnub.AuthenticationKey);
            }

            Uri uri = BuildRequests.BuildRemoveChannelsFromChannelGroupRequest(channels, "", channelGroup,
                                                                               uuid, ssl, pubnub.Origin, pubnub.AuthenticationKey, Common.SubscribeKey
                                                                               );

            string ch     = "";
            string chStr  = "";
            string chStr2 = "/remove";

            if (channels != null && channels.Length > 0)
            {
                ch     = string.Join(",", channels);
                chStr  = string.Format("remove={0}&", Utility.EncodeUricomponent(ch, ResponseType.ChannelGroupRemove, true, false));
                chStr2 = "";
            }

            //http://pubsub.pubnub.com/v1/channel-registration/sub-key/demo-36/channel-group/channelGroup?add=addChannel1,%20addChannel2&uuid=customuuid&auth=authKey&pnsdk=PubNub-CSharp-UnityOSX%2F3.7
            string expected = string.Format("http{0}://{1}/v1/channel-registration/sub-key/{2}/channel-group/{3}{8}?{4}uuid={5}{6}&pnsdk={7}",
                                            ssl?"s":"", pubnub.Origin, Common.SubscribeKey, channelGroup,
                                            chStr, uuid, authKeyString,
                                            Utility.EncodeUricomponent(PubnubUnity.Version, ResponseType.ChannelGroupRemove, false, true),
                                            chStr2

                                            );
            string received = uri.OriginalString;

            Common.LogAndCompare(expected, received);
        }
Beispiel #11
0
        //GetChannels
        //Get All CG
        public void TestBuildGetChannelsForChannelGroupRequestCommon(bool allCg,
                                                                     bool ssl, string authKey)
        {
            string channelGroup    = "channelGroup";
            string channelGroupStr = "channel-group/";

            if (allCg)
            {
                channelGroup    = "";
                channelGroupStr = "channel-group";
            }
            string uuid = "customuuid";

            Pubnub pubnub = new Pubnub(
                Common.PublishKey,
                Common.SubscribeKey,
                "",
                "",
                ssl
                );

            pubnub.AuthenticationKey = authKey;
            string authKeyString = "";

            if (!string.IsNullOrEmpty(authKey))
            {
                authKeyString = string.Format("&auth={0}", pubnub.AuthenticationKey);
            }

            Uri uri = BuildRequests.BuildGetChannelsForChannelGroupRequest("", channelGroup, allCg,
                                                                           uuid, ssl, pubnub.Origin, pubnub.AuthenticationKey, Common.SubscribeKey
                                                                           );

            //http://pubsub.pubnub.com/v1/channel-registration/sub-key/demo-36/channel-group/channelGroup?add=addChannel1,%20addChannel2&uuid=customuuid&auth=authKey&pnsdk=PubNub-CSharp-UnityOSX%2F3.7
            string expected = string.Format("http{0}://{1}/v1/channel-registration/sub-key/{2}/{8}{3}?uuid={5}{6}&pnsdk={7}",
                                            ssl?"s":"", pubnub.Origin, Common.SubscribeKey, channelGroup,
                                            "",
                                            uuid, authKeyString,
                                            Utility.EncodeUricomponent(PubnubUnity.Version, ResponseType.ChannelGroupGet, false, true),
                                            channelGroupStr

                                            );
            string received = uri.OriginalString;

            Common.LogAndCompare(expected, received);
        }
        public void TestBuildTimeRequestCommon(bool ssl){
            string uuid = "customuuid";
            Pubnub pubnub = new Pubnub (
                Common.PublishKey,
                Common.SubscribeKey,
                "",
                "",
                ssl
            );
            Uri uri = BuildRequests.BuildTimeRequest (uuid, ssl, pubnub.Origin);

            //https://pubsub.pubnub.com/time/0?uuid=customuuid&pnsdk=PubNub-CSharp-UnityIOS/3.6.9.0
            string expected = string.Format ("http{0}://{1}/time/0?uuid={2}&pnsdk={3}",
                ssl?"s":"", pubnub.Origin, uuid, 
                Utility.EncodeUricomponent(PubnubUnity.Version, ResponseType.Time, false, false)
            );
            string received = uri.OriginalString;
            Common.LogAndCompare (expected, received);
        }
Beispiel #13
0
        public void TestBuildGetChannelsPushRequestCommon(bool ssl, string authKey, string pushToken, PushTypeService pushType)
        {
            string uuid = "customuuid";

            Pubnub pubnub = new Pubnub(
                Common.PublishKey,
                Common.SubscribeKey,
                "",
                "",
                ssl
                );

            pubnub.AuthenticationKey = authKey;
            string authKeyString = "";

            if (!string.IsNullOrEmpty(authKey))
            {
                authKeyString = string.Format("&auth={0}", pubnub.AuthenticationKey);
            }

            Uri uri = BuildRequests.BuildGetChannelsPushRequest(pushType, pushToken, uuid, ssl,
                                                                pubnub.Origin, pubnub.AuthenticationKey, Common.SubscribeKey
                                                                );

            //[1, "Modified Channels"]
            //["push_channel"]
            //https://pubsub.pubnub.com/v1/push/sub-key/demo-36/devices/pushToken?type=wns&uuid=customuuid&auth=authKey&pnsdk=PubNub-CSharp-UnityIOS/3.6.9.0
            //https://pubsub.pubnub.com/v1/push/sub-key/demo-36/devices/pushToken?type=mpns&uuid=customuuid&auth=authKey&pnsdk=PubNub-CSharp-UnityIOS/3.6.9.0
            string expected = string.Format("http{0}://{1}/v1/push/sub-key/{2}/devices/{3}?type={4}&uuid={5}{6}&pnsdk={7}",
                                            ssl?"s":"", pubnub.Origin, Common.SubscribeKey, pushToken,
                                            pushType.ToString().ToLower(),
                                            uuid, authKeyString, PubnubUnity.Version
                                            );
            string received = uri.ToString();

            UnityEngine.Debug.Log("exp:" + expected);
            UnityEngine.Debug.Log(received);
            Common.LogAndCompare(expected, received);
        }
        public void TestBuildHereNowRequestCommon(bool ssl, bool showUUIDList, bool includeUserState, string authKey)
        {
            string channel = "here_now_channel";
            string uuid    = "customuuid";

            Pubnub pubnub = new Pubnub(
                Common.PublishKey,
                Common.SubscribeKey,
                "",
                "",
                ssl
                );

            pubnub.AuthenticationKey = authKey;
            string authKeyString = "";

            if (!string.IsNullOrEmpty(authKey))
            {
                authKeyString = string.Format("&auth={0}", pubnub.AuthenticationKey);
            }

            int    disableUUID = (showUUIDList) ? 0 : 1;
            int    userState   = (includeUserState) ? 1 : 0;
            string parameters  = string.Format("disable_uuids={0}&state={1}", disableUUID, userState);

            Uri uri = BuildRequests.BuildHereNowRequest(channel, showUUIDList, includeUserState,
                                                        uuid, ssl, pubnub.Origin, pubnub.AuthenticationKey, Common.SubscribeKey
                                                        );

            //http://pubsub.pubnub.com/v2/presence/sub_key/demo-36/channel/here_now_channel?disable_uuids=1&state=0&uuid=customuuid&auth=authKey&pnsdk=PubNub-CSharp-UnityOSX/3.6.9.0
            string expected = string.Format("http{0}://{1}/v2/presence/sub_key/{2}/channel/{3}?{4}&uuid={5}{6}&pnsdk={7}",
                                            ssl?"s":"", pubnub.Origin, Common.SubscribeKey, channel, parameters,
                                            uuid, authKeyString, PubnubUnity.Version
                                            );
            string received = uri.ToString();

            Common.LogAndCompare(expected, received);
        }
Beispiel #15
0
        public void TestBuildPublishRequestCommonWithTTL(bool sendMeta, bool ssl, bool storeInHistory, string secretKey,
                                                         string cipherKey, string authKey, int ttl)
        {
            string channel   = "publish_channel";
            string message   = "Test message";
            string uuid      = "customuuid";
            string signature = "0";
            Pubnub pubnub    = new Pubnub(
                Common.PublishKey,
                Common.SubscribeKey,
                secretKey,
                cipherKey,
                ssl
                );

            pubnub.AuthenticationKey = authKey;
            string authKeyString = "";

            if (!string.IsNullOrEmpty(authKey))
            {
                authKeyString = string.Format("&auth={0}", pubnub.AuthenticationKey);
            }

            string meta     = "";
            string metadata = "{\"region\":\"east\"}";

            if (sendMeta)
            {
                meta = string.Format("&meta={0}", Utility.EncodeUricomponent(metadata, ResponseType.Publish, false, false));
            }
            else
            {
                metadata = "";
            }

            string originalMessage = Helpers.JsonEncodePublishMsg(message, cipherKey, pubnub.JsonPluggableLibrary);

            if (secretKey.Length > 0)
            {
                StringBuilder stringToSign = new StringBuilder();
                stringToSign
                .Append(Common.PublishKey)
                .Append('/')
                .Append(Common.SubscribeKey)
                .Append('/')
                .Append(secretKey)
                .Append('/')
                .Append(channel)
                .Append('/')
                .Append(originalMessage);      // 1

                // Sign Message
                signature = Utility.Md5(stringToSign.ToString());
            }

            Uri uri = BuildRequests.BuildPublishRequest(channel, originalMessage, storeInHistory, uuid, ssl,
                                                        pubnub.Origin, pubnub.AuthenticationKey, Common.PublishKey, Common.SubscribeKey,
                                                        cipherKey, secretKey, metadata, 0, ttl
                                                        );

            string ttlStr = (ttl == -1) ? "" : string.Format("&ttl={0}", ttl.ToString());

            //http://pubsub.pubnub.com/publish/demo-36/demo-36/0/publish_channel/0?uuid=customuuid&auth=authKey&pnsdk=PubNub-CSharp-UnityOSX/3.6.9.0
            string expected = string.Format("http{0}://{1}/publish/{2}/{3}/{4}/{5}/0/{6}?uuid={7}&seqn=0{8}{12}{11}{9}&pnsdk={10}",
                                            ssl?"s":"", pubnub.Origin, Common.PublishKey, Common.SubscribeKey, signature, channel,
                                            Utility.EncodeUricomponent(originalMessage, ResponseType.Publish, false, false),
                                            uuid, storeInHistory?"":"&store=0", authKeyString,
                                            Utility.EncodeUricomponent(PubnubUnity.Version, ResponseType.Publish, false, false),
                                            meta,
                                            ttlStr
                                            );
            string received = uri.OriginalString;

            Common.LogAndCompare(expected, received);
        }