예제 #1
0
파일: BaseMod.cs 프로젝트: anda12/Mars
        public int RequestGetData(string name, string sdata, out string rdata)
        {
            if (RequestRM.ContainsKey(name))
            {
                RequestRun rr = RequestRM[name];

                rr.req.SendFrame(sdata);
                try
                {
                    rdata = rr.req.ReceiveFrameString();
                    return(0);
                }
                catch (Exception err)
                {
                    Logging.logger.Error("receive data failed " + err.Message);
                    rdata = string.Empty;
                    return(-1);
                }
            }
            else
            {
                rdata = string.Empty;
                return(-1);
            }
        }
예제 #2
0
파일: BaseMod.cs 프로젝트: anda12/Mars
        public int RequestService()
        {
            if (ModRequests.Count > 0)
            {
                foreach (Point p in ModRequests)
                {
                    if (RequestRM.ContainsKey(p.name))
                    {
                        Logging.logger.Warn("the request is exist " + p.name);
                        continue;
                    }
                    else
                    {
                        RequestRun    rr = new RequestRun();
                        RequestSocket r  = new RequestSocket();

                        string e = "tcp://" + p.ip + ":" + p.port;
                        try
                        {
                            r.Connect(e);
                            rr.name    = p.name;
                            rr.point   = p;
                            rr.req     = r;
                            rr.Running = true;
                            rr.Working = false;
                        }
                        catch (Exception err)
                        {
                            Logging.logger.Error(ModName + " connect request socket failed " + e + " " + err.Message);
                            throw (err);
                        }

                        RequestRM.Add(p.name, rr);
                    }
                }
            }

            return(0);
        }