Ejemplo n.º 1
0
        void CheckToRemoteServer(object o)
        {
            if (o == null)
            {
                return;
            }
            //string om = (string)o;
            // operateMessage om = (operateMessage)o;
            //if (om != "")
            //{
            deleControlInvoke dele = delegate(object oepc)
            {
                string id = (string)oepc;
                //if (AddEPC2List(id))
                if (!epcList.Contains(id) && !ProcessingepcList.Contains(id))
                {
                    AsynchronousSocketClient asc = new AsynchronousSocketClient();
                    asc.eventProcessMsg += new deleAsynSocketProcessMsg(asc_eventProcessMsg);
                    try
                    {
                        ProcessingepcList.Add(id);
                        asc.StartClient(id, _IP, _Port);
                    }
                    catch (System.Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                        return;
                    }
                }
            };

            this.Invoke(dele, o);
            //}
        }
Ejemplo n.º 2
0
        private void btnConnection_Click(object sender, EventArgs e)
        {
            asynchronousClient = new AsynchronousSocketClient(AsynchronousData);
            synchroClient.Connect(ServiceIP, 7777);
            asynchronousClient.Connect(ServiceIP, 7777);



            HelloWCF.Connection();
            HelloAsyWCF.Connection();
            btnStart.Enabled    = true;
            btnSendMess.Enabled = true;
        }
Ejemplo n.º 3
0
        public async Task <XDocument> Transmit(XDataMessageRequest x)
        {
            try
            {
                Status = CommStatus.CONNECTED;
                if (_session == null)
                {
                    await getSocksConnection();
                }
                var msgOut = new Message();
                var encryptedCompressedMsgOut = new EncryptMessageOutput(new CompressMessageOutput(msgOut))
                {
                    MsgIn = x.ToString()
                };
                await encryptedCompressedMsgOut.process();

                var Socket = new AsynchronousSocketClient()
                {
                    ServerIP = IP, ServerPort = Port
                };
                var _result = await Socket.AsyncConversation(encryptedCompressedMsgOut.MsgOut);

                if (_result == "" || _result.Substring(0, 5) == "ERROR")
                {
                    throw new Exception(_result);
                }
                var msgIn = new Message();
                var decryptedUncompressedMsgIn = new DecryptMessageInput(new DecompressMessageInput(msgIn))
                {
                    MsgIn = _result
                };
                await decryptedUncompressedMsgIn.process();

                //Thread.Sleep(2000);
                //var m = new TransmitEntcryptedCompressedMessage() { ServerIP = IP, Port = Port };
                //m.MsgIn = x.ToString();
                //await m.process();
                //var _res= XDocument.Parse(m.MsgOut);
                var _res = XDocument.Parse(decryptedUncompressedMsgIn.MsgOut);
                Status = CommStatus.OFFLINE;
                return(_res);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Status = CommStatus.ERROR;
                throw e;
            }
        }
Ejemplo n.º 4
0
        public async Task <bool> process()
        {
            try
            {
                var Socket = new AsynchronousSocketClient()
                {
                    ServerIP = ServerIP, ServerPort = Port
                };
                MsgOut = await Socket.AsyncConversation(MsgIn);

                //var task = Socket.AsyncConversation(MsgIn);
                //task.Wait();
                //await task;
                //MsgOut = task.Result;

                //MsgOut = Socket.SyncConversation(MsgIn);
                return(true);
            } catch (Exception ex)
            {
                MsgOut = "Error: " + ex.Message;
                return(false);
            }
        }
        protected void Application_Start()
        {
            var builder = new ContainerBuilder();

            // Register your MVC controllers. (MvcApplication is the name of
            // the class in Global.asax.)
            builder.RegisterControllers(typeof(MvcApplication).Assembly);

            builder.RegisterType <UnitOfWork>().As <IUnitOfWork>();

            // Set the dependency resolver to be Autofac.
            var container = builder.Build();

            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));

            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //SynchronousSocketClient.StartClient();
            AsynchronousSocketClient.StartClient();
        }
Ejemplo n.º 6
0
        public async Task <string> Transmit(string s)
        {
            var msgOut = new Message();
            var encryptedCompressedMsgOut = new EncryptMessageOutput(new CompressMessageOutput(msgOut))
            {
                MsgIn = s
            };
            await encryptedCompressedMsgOut.process();

            var Socket = new AsynchronousSocketClient()
            {
                ServerIP = IP, ServerPort = Port
            };
            var _result = Socket.SyncConversation(encryptedCompressedMsgOut.MsgOut);
            var msgIn   = new Message();
            var decryptedUncompressedMsgIn = new DecompressMessageInput(new DecryptMessageInput(msgIn))
            {
                MsgIn = _result
            };
            await decryptedUncompressedMsgIn.process();

            return(decryptedUncompressedMsgIn.MsgOut);
        }
Ejemplo n.º 7
0
 public DefaultReader(AsynchronousSocketClient client)
 {
     this.client = client;
 }