Ejemplo n.º 1
0
        private void threadStartFun(Socket soc, string req)
        {
            try
            {
                Program.ServerForm.addtoConsole("Service Poll Req Thread Started");
                Server.Message.MessageParser serverPollPar = new Server.Message.MessageParser();
                Server.MessageClasses.MsgPoll msgpollServer = serverPollPar.pollParseMsg(req);

                CloudBlobClient blobClient = new Server.ConnectionManager.BlobConn().BlobConnect();
                Blob blob = new Blob(blobClient, msgpollServer.userName);
                GenerateSAS sas = new GenerateSAS();
                string link = "";
                if (msgpollServer.password == "requestVC")
                {
                    link = sas.GetContainerSasUri(blob.container, "RWLD");
                }
                else
                {
                    link = sas.GetContainerSasUri(blob.container, "RWLD");
                }

                // Server send response to Client
                Server.Message.CreateMsg pollResp = new Server.Message.CreateMsg();
                msgpollServer.fileContainerUri = link;
                msgpollServer.fileBlobUri = "none";
                string respMsg = pollResp.pollRespMsg("OK", msgpollServer);

                //socket
                SocketCommunication.ReaderWriter rw = new SocketCommunication.ReaderWriter();
                // write to socket
                rw.writetoSocket(soc, respMsg);
                Program.ServerForm.addtoConsole("Wrote Response to socket");

            }
            catch (Exception e)
            {
                Program.ServerForm.addtoConsole("Exception: [Poll Req]"+ e.Message);
                //System.Windows.Forms.MessageBox.Show(e.ToString());
            }
            finally
            {
                Program.ServerForm.addtoConsole("Exiting");
                Thread.CurrentThread.Abort();
            }
        }
Ejemplo n.º 2
0
        public void startCopyBlob()
        {
            if (!Service_BlobSync.blobsSync)
            {
                return;
            }

            BlobConn conn = new BlobConn();
            var srcBlobClient = conn.BlobConnect();
            if (conn.currentBlob == 1)
            {
                var dstBlobClient = conn.getSpecifyClient(2);
                if (dstBlobClient != null)
                {
                    delete(srcBlobClient, dstBlobClient);
                    Copy(srcBlobClient, dstBlobClient);
                }
                dstBlobClient = conn.getSpecifyClient(3);
                if (dstBlobClient != null)
                {
                    delete(srcBlobClient, dstBlobClient);
                    Copy(srcBlobClient, dstBlobClient);
                }
            }
            else if (conn.currentBlob == 2)
            {
                var dstBlobClient = conn.getSpecifyClient(3);
                if (dstBlobClient != null)
                {
                    delete(srcBlobClient, dstBlobClient);
                    Copy(srcBlobClient, dstBlobClient);
                }

            }

            Console.WriteLine("done sync blob");
        }
Ejemplo n.º 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);
        }