Exemplo n.º 1
0
        public bool SendToUser <T>(T requestNode)
        {
            if (requestNode == null)
            {
                return(false);
            }

            Protocol.ProtocolBase protocolBase = requestNode as Protocol.ProtocolBase;
            protocolBase.senderId = this.userId;
            string requestJsonString = Util.Encode <T>(requestNode);

            socket.EmitJson("to", requestJsonString);

            return(true);
        }
Exemplo n.º 2
0
        public bool SendToAll <T>(T requestNode)
        {
            if (requestNode == null)
            {
                return(false);
            }

            Protocol.ProtocolBase protocolBase = requestNode as Protocol.ProtocolBase;
            protocolBase.senderId = this.userId;

            string requestJsonString = Util.Encode <T>(requestNode);

            Debug.Log("requestJsonString=" + requestJsonString);

            socket.EmitJson("broadcast", requestJsonString);

            return(true);
        }
        static int __CreateInstance(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
                if (LuaAPI.lua_gettop(L) == 2 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2))
                {
                    int proto = LuaAPI.xlua_tointeger(L, 2);

                    Protocol.ProtocolBase __cl_gen_ret = new Protocol.ProtocolBase(proto);
                    translator.Push(L, __cl_gen_ret);

                    return(1);
                }
            }
            catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
            return(LuaAPI.luaL_error(L, "invalid arguments to Protocol.ProtocolBase constructor!"));
        }
        static int _m_Pack(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                Protocol.ProtocolBase __cl_gen_to_be_invoked = (Protocol.ProtocolBase)translator.FastGetCSObj(L, 1);


                int __gen_param_count = LuaAPI.lua_gettop(L);

                if (__gen_param_count == 3 && translator.Assignable <MsgPack>(L, 2) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 3))
                {
                    MsgPack packer = (MsgPack)translator.GetObject(L, 2, typeof(MsgPack));
                    bool    clear  = LuaAPI.lua_toboolean(L, 3);

                    __cl_gen_to_be_invoked.Pack(packer, clear);



                    return(0);
                }
                if (__gen_param_count == 2 && translator.Assignable <MsgPack>(L, 2))
                {
                    MsgPack packer = (MsgPack)translator.GetObject(L, 2, typeof(MsgPack));

                    __cl_gen_to_be_invoked.Pack(packer);



                    return(0);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }

            return(LuaAPI.luaL_error(L, "invalid arguments to Protocol.ProtocolBase.Pack!"));
        }
        static int _m_SendMsg(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                WsGame __cl_gen_to_be_invoked = (WsGame)translator.FastGetCSObj(L, 1);



                {
                    Protocol.ProtocolBase msg = (Protocol.ProtocolBase)translator.GetObject(L, 2, typeof(Protocol.ProtocolBase));

                    __cl_gen_to_be_invoked.SendMsg(msg);



                    return(0);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
Exemplo n.º 6
0
        /// <summary>Read data from byte array</summary>
        /// <param name="protocol">Reference to ecu protocol</param>
        /// <returns>True on success</returns>
        public ReturnValue Read(ref Protocol.ProtocolBase protocol)
        {
            byte[]      buffer;
            ReturnValue ret = protocol.ReadDtc(out buffer);

            if (buffer != null)
            {
                if ((buffer.Length != 271) && (buffer.Length != 275))
                {
                    ret = ReturnValue.SizeMismatch;
                }
                else
                {
                    mWarmUpNumberSinceCleared = BitConverter.ToUInt16(buffer, 0);
                    mTimeOfCleared            = BitConverter.ToUInt32(buffer, 2);
                    mStartTimeMil             = BitConverter.ToUInt32(buffer, 6);
                    //mStack;
                    for (int i = 0; i < mStack.Length; i++)
                    {
                        mStack[i]                  = new TroubleCodeItem();
                        mStack[i].FreeWarmUps      = (byte)(buffer[10 + 0 + (i * 4)] & 0x7F);
                        mStack[i].ErrorNumber      = (byte)(buffer[10 + 1 + (i * 4)]);
                        mStack[i].OccuranceCounter = (byte)(buffer[10 + 2 + (i * 4)]);
                        mStack[i].isPending        = (byte)((buffer[10 + 3 + (i * 4)] & 0xC0) / 64);
                        mStack[i].isActive         = (byte)((buffer[10 + 3 + (i * 4)] & 0x20) / 32);
                        mStack[i].isPrevActive     = (byte)((buffer[10 + 3 + (i * 4)] & 0x10) / 16);
                        if (mStack[i].ErrorNumber != 0)
                        {
                            if (mSuspectParameterNumber.Length >= mStack[i].ErrorNumber)
                            {
                                mStack[i].SuspectParameterNumber = mSuspectParameterNumber[mStack[i].ErrorNumber];
                            }
                            else
                            {
                                mStack[i].SuspectParameterNumber = 0;
                            }
                            if (mFailureModeIdentifier.Length >= mStack[i].ErrorNumber)
                            {
                                mStack[i].FailureModeIdentifier = mFailureModeIdentifier[mStack[i].ErrorNumber];
                            }
                            else
                            {
                                mStack[i].FailureModeIdentifier = 0;
                            }
                        }
                        else
                        {
                            mStack[i].SuspectParameterNumber = 0;
                            mStack[i].FailureModeIdentifier  = 0;
                        }
                    }

                    mFreezeFrameErrorNumber        = buffer[266];
                    mFreezeFrameRpm                = BitConverter.ToUInt16(buffer, 267);
                    mFreezeFrameEngineLoad         = buffer[269];
                    mFreezeFrameCoolantTemperature = buffer[270];
                    if (buffer.Length > 273)
                    {
                        mDeratingLevel = BitConverter.ToUInt16(buffer, 271);
                        mDtcFlags      = BitConverter.ToUInt16(buffer, 273);
                    }
                    else
                    {
                        mDeratingLevel = 0;
                        mDtcFlags      = 0;
                    }
                }
            }
            return(ret);
        }