예제 #1
0
        public MsgPoll pollParseMsg(string msg)
        {
            MsgPoll msgPoll = new MsgPoll();
            string[] separators = { "<", ">:<", ">" };
            string[] words = msg.Split(separators, StringSplitOptions.RemoveEmptyEntries);

            msgPoll.indicator = words[0];

            if (msgPoll.indicator == "OK")
            {
                msgPoll.fileContainerUri = words[2];
                msgPoll.fileBlobUri = words[3];
            }

            return msgPoll;
        }
예제 #2
0
        /// <summary>
        /// poll protocol
        /// +--------------------------+
        /// |POLL:<userName>:<password>|
        /// +--------------------------+
        /// </summary>
        /// <param name="msgpoll"></param>
        /// <returns></returns>
        public string pollMsg(MsgPoll msgpoll)
        {
            string msg = "<POLL>:<" + msgpoll.userName + ">:<" + msgpoll.password + ": <" + msgpoll.nodeInfo + ">" + ":<EOF>";

            return msg;
        }
예제 #3
0
        public void interPollTest()
        {
            // 1. Client create and send poll msg to Server
                Client.Message.CreateMsg pollM = new Client.Message.CreateMsg();
                Client.MessageClasses.MsgPoll msgpoll = new Client.MessageClasses.MsgPoll();
                msgpoll.userName = "******";
                msgpoll.password = "******";
                string pollCtoS = pollM.pollMsg(msgpoll);
                Console.WriteLine("msg from client to server: " + pollCtoS);

                // 2. Server parse msg and create sas uri
                Server.Message.MessageParser serverPollPar = new Server.Message.MessageParser();
                Server.MessageClasses.MsgPoll msgpollServer = serverPollPar.pollParseMsg(pollCtoS);
                string resp = "";
                try
                {
                    CloudBlobClient blobClient = new Server.ConnectionManager.BlobConn().BlobConnect();
                    Blob blob = new Blob(blobClient, msgpollServer.userName);
                    GenerateSAS sas = new GenerateSAS();
                    string link = sas.GetContainerSasUri(blob.container, "RL");
                    // 3. Server send response to Client
                    Server.Message.CreateMsg pollResp = new Server.Message.CreateMsg();
                    msgpollServer.fileContainerUri = link;
                    msgpollServer.fileBlobUri = "none";
                    resp = pollResp.pollRespMsg("OK", msgpollServer);

                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }

                //4. Client parse and poll
                Client.Message.MessageParser pollGetClient = new Client.Message.MessageParser();
                msgpoll = pollGetClient.pollParseMsg(resp);
                new Client.PollFunction.Poll(msgpoll.fileContainerUri);
        }