Esempio n. 1
0
        void Parent_GetArgs(object sender, Communicate.Base.Base.ReciveArgs reciveArgs)
        {
            lock (lockObject)
            {
                Communicate.Communicate parent = (Communicate.Communicate)sender;
                int    len = parent.DataRecive;
                byte[] buff;
                if (len > 0 && this.Read <byte[]>(len, out buff))
                {
                    SSMeter.SSReadMeter.ReadDataStyle   rs = SSMeter.SSReadMeter.ReadDataStyle.Parse(buff);
                    SSMeter.SSReadMeter.ReadResultStyle rr = new SSMeter.SSReadMeter.ReadResultStyle(Class.TypeUse.TypeList.Int, rs.Random, true, null);
                    if (rs == null)
                    {
                        All.Class.Error.Add("SSLockClient.Loop无校验或校验不通过");
                        return;
                    }
                    if (!rs.Symbol.ContainsKey("GUID"))
                    {
                        All.Class.Error.Add("SSLockMain接收的字符串没有GUID识别码");
                        return;
                    }
                    if (!Queue.Contain(rs.Symbol["GUID"]))
                    {
                        allClientReturnStatue.Add(rs.Symbol["GUID"], ReturnStatueList.无请求);
                        allClientRequestStatue.Add(rs.Symbol["GUID"], SSLockClient.SetStatueList.无动作);
                        Queue.Init(0, rs.Symbol["GUID"]);
                    }
                    if (!rs.Symbol.ContainsKey("Code"))
                    {
                        All.Class.Error.Add("SSLockMain接收的字符串没有Code命令码");
                        return;
                    }

                    allClientRequestStatue[rs.Symbol["GUID"]] = (SSLockClient.SetStatueList)rs.Symbol["Code"].ToInt();

                    rr.Result = true;
                    rr.Value  = new List <int>()
                    {
                        (int)allClientReturnStatue[rs.Symbol["GUID"]]
                    };
                    Dictionary <string, string> parm = new Dictionary <string, string>();
                    parm.Add("RemotIP", reciveArgs.RemotIP);
                    parm.Add("RemotPort", reciveArgs.RemotPort.ToString());
                    parent.Send <byte[]>(rr.GetBytes <int>(), parm);
                }
            }
        }
Esempio n. 2
0
        private void Parent_GetArgs(object sender, Communicate.Base.Base.ReciveArgs reciveArgs)
        {
            lock (lockObject)
            {
                Communicate.Communicate parent = (Communicate.Communicate)sender;
                int    len = parent.DataRecive;
                byte[] buff;
                if (len > 0 && this.Read <byte[]>(len, out buff))
                {
                    SSMeter.SSWriteMeter.WriteDataStyle ds = SSMeter.SSWriteMeter.WriteDataStyle.Parse(buff);
                    if (ds == null)
                    {
                        return;
                    }
                    SSMeter.SSWriteMeter.WriteResultStyle rs = new SSMeter.SSWriteMeter.WriteResultStyle(ds.Random, false);
                    if (ds.Value != null)
                    {
                        rs.Result = true;
                        switch (ds.Type)
                        {
                        case Class.TypeUse.TypeList.Boolean:
                            tmpBool = (List <bool>)ds.Value;
                            for (int i = ds.Start; i < boolValue.Length && i < ds.Start + tmpBool.Count; i++)
                            {
                                boolValue[i] = tmpBool[i - ds.Start];
                            }
                            break;

                        case Class.TypeUse.TypeList.Byte:
                            tmpByte = (List <byte>)ds.Value;
                            for (int i = ds.Start; i < byteValue.Length && i < ds.Start + tmpByte.Count; i++)
                            {
                                byteValue[i] = tmpByte[i - ds.Start];
                            }
                            break;

                        case Class.TypeUse.TypeList.DateTime:
                            tmpDateTime = (List <DateTime>)ds.Value;
                            for (int i = ds.Start; i < dateTimeValue.Length && i < ds.Start + tmpDateTime.Count; i++)
                            {
                                dateTimeValue[i] = tmpDateTime[i - ds.Start];
                            }
                            break;

                        case Class.TypeUse.TypeList.Double:
                            tmpDouble = (List <double>)ds.Value;
                            for (int i = ds.Start; i < doubleValue.Length && i < ds.Start + tmpDouble.Count; i++)
                            {
                                doubleValue[i] = tmpDouble[i - ds.Start];
                            }
                            break;

                        case Class.TypeUse.TypeList.Float:
                            tmpFloat = (List <float>)ds.Value;
                            for (int i = ds.Start; i < floatValue.Length && i < ds.Start + tmpFloat.Count; i++)
                            {
                                floatValue[i] = tmpFloat[i - ds.Start];
                            }
                            break;

                        case Class.TypeUse.TypeList.Int:
                            tmpInt = (List <int>)ds.Value;
                            for (int i = ds.Start; i < intValue.Length && i < ds.Start + tmpInt.Count; i++)
                            {
                                intValue[i] = tmpInt[i - ds.Start];
                            }
                            break;

                        case Class.TypeUse.TypeList.Long:
                            tmpLong = (List <long>)ds.Value;
                            for (int i = ds.Start; i < longValue.Length && i < ds.Start + tmpLong.Count; i++)
                            {
                                longValue[i] = tmpLong[i - ds.Start];
                            }
                            break;

                        case Class.TypeUse.TypeList.String:
                            tmpString = (List <string>)ds.Value;
                            for (int i = ds.Start; i < stringValue.Length && i < ds.Start + tmpString.Count; i++)
                            {
                                stringValue[i] = tmpString[i - ds.Start];
                            }
                            break;

                        case Class.TypeUse.TypeList.UShort:
                            tmpUshort = (List <ushort>)ds.Value;
                            for (int i = ds.Start; i < ushortValue.Length && i < ds.Start + tmpUshort.Count; i++)
                            {
                                ushortValue[i] = tmpUshort[i - ds.Start];
                            }
                            break;
                        }
                    }
                    if (parent is Communicate.Udp)
                    {
                        Dictionary <string, string> parm = new Dictionary <string, string>();
                        parm.Add("RemotHost", reciveArgs.RemotIP);
                        parm.Add("RemotPort", reciveArgs.RemotPort.ToString());
                        parent.Send <byte[]>(rs.GetBytes(), parm);
                    }
                    else
                    {
                        parent.Send <byte[]>(rs.GetBytes());
                    }
                }
            }
        }