示例#1
0
        internal bool GetCommunicationModuleOffset(string moduleName, out ushort synReqOffset, out ushort synReqRspOffset, out ushort asynReqOffset)
        {
            /******************
            * Comm. protocol:
            *  - REQUEST : [char_cnt, char[] moduleName]
            *  - RESPONSE: [int synReqOffset, int synReqRspOffset, int asynReqOffset]
            * An response error code other than E_SUCCESS indicates failure of remote module lookup.
            ******************/

            using (TrinityMessage tm = new TrinityMessage(
                       TrinityMessageType.PRESERVED_SYNC_WITH_RSP,
                       (ushort)RequestType.GetCommunicationModuleOffsets,
                       size: sizeof(int) + sizeof(char) * moduleName.Length))
            {
                SmartPointer sp = SmartPointer.New(tm.Buffer + TrinityMessage.Offset);
                *sp.ip++        = moduleName.Length;

                BitHelper.WriteString(moduleName, sp.bp);
                TrinityResponse response;
                this.SendMessage(tm, out response);

                sp.bp = response.Buffer + response.Offset;
                int synReq_msg    = *sp.ip++;
                int synReqRsp_msg = *sp.ip++;
                int asynReq_msg   = *sp.ip++;

                synReqOffset    = (ushort)synReq_msg;
                synReqRspOffset = (ushort)synReqRsp_msg;
                asynReqOffset   = (ushort)asynReq_msg;

                return(response.ErrorCode == TrinityErrorCode.E_SUCCESS);
            }
        }
示例#2
0
        internal void GetCommunicationSchema(out string name, out string signature)
        {
            /******************
            * Comm. protocol:
            *  - REQUEST : VOID
            *  - RESPONSE: [char_cnt, char[] name, char_cnt, char[] sig]
            ******************/
            using (TrinityMessage tm = new TrinityMessage(
                       TrinityMessageType.PRESERVED_SYNC_WITH_RSP,
                       (ushort)RequestType.GetCommunicationSchema,
                       size: 0))
            {
                TrinityResponse response;
                this.SendMessage(tm, out response);
                SmartPointer sp = SmartPointer.New(response.Buffer + response.Offset);
                int          name_string_len = *sp.ip++;
                name   = BitHelper.GetString(sp.bp, name_string_len * 2);
                sp.cp += name_string_len;
                int sig_string_len = *sp.ip++;
                signature = BitHelper.GetString(sp.bp, sig_string_len * 2);

                response.Dispose();
            }
        }