当前位置: 首页>>代码示例>>C#>>正文


C# Msg类代码示例

本文整理汇总了C#中Msg的典型用法代码示例。如果您正苦于以下问题:C# Msg类的具体用法?C# Msg怎么用?C# Msg使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Msg类属于命名空间,在下文中一共展示了Msg类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Send

	public void Send(Msg msg)
	{
        if (client != null && client.Connected)
            Send(msg.ToCArray());
        else
            sendQueue.Add(msg);
	}
开发者ID:toophy,项目名称:hugular_cstolua,代码行数:7,代码来源:LNet.cs

示例2: constructor

 public static int constructor(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         Msg o;
         if(argc==1){
             o=new Msg();
             pushValue(l,true);
             pushValue(l,o);
             return 2;
         }
         else if(argc==2){
             System.Byte[] a1;
             checkType(l,2,out a1);
             o=new Msg(a1);
             pushValue(l,true);
             pushValue(l,o);
             return 2;
         }
         return error(l,"New object failed.");
     }
     catch(Exception e) {
         return error(l,e);
     }
 }
开发者ID:dafei2015,项目名称:hugula,代码行数:25,代码来源:Lua_Msg.cs

示例3: XSetSocketOption

        /// <summary>
        /// Set the specified option on this socket - which must be either a SubScribe or an Unsubscribe.
        /// </summary>
        /// <param name="option">which option to set</param>
        /// <param name="optionValue">the value to set the option to</param>
        /// <returns><c>true</c> if successful</returns>
        /// <exception cref="InvalidException">optionValue must be a String or a byte-array.</exception>
        protected override bool XSetSocketOption(ZmqSocketOption option, object optionValue)
        {
            // Only subscribe/unsubscribe options are supported
            if (option != ZmqSocketOption.Subscribe && option != ZmqSocketOption.Unsubscribe)
                return false;

            byte[] topic;
            if (optionValue is string)
                topic = Encoding.ASCII.GetBytes((string)optionValue);
            else if (optionValue is byte[])
                topic = (byte[])optionValue;
            else
                throw new InvalidException($"In Sub.XSetSocketOption({option},{optionValue?.ToString() ?? "null"}), optionValue must be either a string or a byte-array.");

            // Create the subscription message.
            var msg = new Msg();
            msg.InitPool(topic.Length + 1);
            msg.Put(option == ZmqSocketOption.Subscribe ? (byte)1 : (byte)0);
            msg.Put(topic, 1, topic.Length);

            try
            {
                // Pass it further on in the stack.
                var isMessageSent = base.XSend(ref msg);

                if (!isMessageSent)
                    throw new Exception($"in Sub.XSetSocketOption({option}, {optionValue}), XSend returned false.");
            }
            finally
            {
                msg.Close();
            }

            return true;
        }
开发者ID:cjkao,项目名称:netmq,代码行数:42,代码来源:Sub.cs

示例4: Main

        static void Main(string[] args)
        {
            using (IRiakEndPoint endpoint = RiakCluster.FromConfig("riakConfig"))
            {
                IRiakClient client = endpoint.CreateClient();
                UserRepository userRepo = new UserRepository(client);
                MsgRepository msgRepo = new MsgRepository(client);
                TimelineRepository timelineRepo = new TimelineRepository(client);
                TimelineManager timelineMgr = new TimelineManager(timelineRepo, msgRepo);

                // Create and save users
                var marleen = new User("marleenmgr", "Marleen Manager", "[email protected]");
                var joe = new User("joeuser", "Joe User", "[email protected]");
                userRepo.Save(marleen);
                userRepo.Save(joe);

                // Create new Msg, post to timelines
                Msg msg = new Msg(marleen.UserName, joe.UserName, "Welcome to the company!");
                timelineMgr.PostMsg(msg);

                // Get Joe's inbox for today, get first message
                Timeline joesInboxToday = timelineMgr.GetTimeline(joe.UserName, Timeline.TimelineType.Inbox, DateTime.UtcNow);
                Msg joesFirstMsg = msgRepo.Get(joesInboxToday.MsgKeys.First());

                Console.WriteLine("From: " + joesFirstMsg.Sender);
                Console.WriteLine("Msg : " + joesFirstMsg.Text);
            }
        }
开发者ID:vixletadmin,项目名称:taste-of-riak,代码行数:28,代码来源:Program.cs

示例5: CopyPooled

        public void CopyPooled()
        {
            var pool = new MockBufferPool();
            BufferPool.SetCustomBufferPool(pool);

            var msg = new Msg();
            msg.InitPool(100);

            Assert.IsFalse(msg.IsShared);

            var copy = new Msg();
            copy.Copy(ref msg);

            Assert.IsTrue(msg.IsShared);
            Assert.IsTrue(copy.IsShared);

            msg.Close();

            Assert.AreEqual(0, pool.ReturnCallCount);
            Assert.IsFalse(msg.IsInitialised);
            Assert.IsNull(msg.Data);

            copy.Close();

            Assert.AreEqual(1, pool.ReturnCallCount);
            Assert.IsFalse(copy.IsInitialised);
            Assert.IsNull(copy.Data);
        }
开发者ID:wangkai2014,项目名称:netmq,代码行数:28,代码来源:MsgTests.cs

示例6: Plug

        public void Plug(IOThread ioThread, SessionBase session)
        {
            m_session = session;
            m_encoder.SetMsgSource(session);

            // get the first message from the session because we don't want to send identities
            var msg = new Msg();
            msg.InitEmpty();

            bool ok = session.PullMsg(ref msg);

            if (ok)
            {
                msg.Close();
            }

            AddSocket(m_socket);            

            if (!m_delayedStart)
            {
                StartConnecting();
            }
            else
            {
                m_state = State.Delaying;                
                AddTimer(GetNewReconnectIvl(), ReconnectTimerId);
            }
        }
开发者ID:NetMQ,项目名称:NetMQ3-x,代码行数:28,代码来源:PgmSender.cs

示例7: HandleInformation

        /// <summary>
        /// 处理接收到的信息(包括大数据块信息)。
        /// </summary>
        /// <param name="sourceUserID">发出信息的用户ID。如果为null,表示信息来自服务端。</param>
        /// <param name="informationType">自定义信息类型</param>
        /// <param name="info">信息</param>
        public void HandleInformation(string sourceUserID, int informationType, byte[] info)
        {
            MessageBox.Show("xxxxx");
            if (sourceUserID != null)
            {
                switch (informationType)
                {
                    case 1://普通文本消息
                        //取出收到的消息,接收者ID卍发送者ID卍消息内容卍发送时间卍发送人名字
                        string message = System.Text.Encoding.UTF8.GetString(info);

                        string[] msgs = Regex.Split(message, Constant.SPLIT, RegexOptions.IgnoreCase);//得到含有5个元素的数组
                        Msg msg = new Msg(msgs, 1, 0);//消息存在msg对象中

                        ChatListSubItem[] items = chatListBox_contacts.GetSubItemsById(Convert.ToUInt32(sourceUserID));//按照ID查找listbox中的用户
                        string windowsName = items[0].NicName + ' ' + items[0].ID;//聊天窗口的标题
                        IntPtr handle = NativeMethods.FindWindow(null, windowsName);//查找是否已经存在窗口
                        if (handle != IntPtr.Zero)//如果聊天窗口已存在
                        {
                            Form frm = (Form)Form.FromHandle(handle);
                            frm.Activate();//激活
                            this.OnReceive(msg);//传送消息到聊天窗口
                        }
                        else//聊天窗口不存在
                        {
                            MsgDB db = MsgDB.OpenMsgDB(myInfo.ID.ToString());
                            //db.addMsg(msg);
                            twinkle(chatListBox_contacts, Convert.ToUInt32(sourceUserID));//头像闪烁
                        }
                        break;
                    case 2:
                        break;
                }
            }
        }
开发者ID:wangyuqin,项目名称:MinChat,代码行数:41,代码来源:Form_main.cs

示例8: FormRequest

    private List<MsgRequest> FormRequest()
    {
		List<MsgRequest> ret = new List<MsgRequest> ();
		//if (elist.Count == 0) {
		//	return null;
		//}
		var elist = EventReporter.ReportEvent ();
        foreach (var e in elist)
        {
			var req = new MsgRequest();
			var head = new Head();
			var content = new Content();
			var msg = new Msg();
			head.srcID = e.sponsorId;
			head.srcType = SRCType.UNITYC;
			head.dstIDs.InsertRange(0,e.targetIdList);
			msg.type = Support.MsgTypeConverter(e.type);
			msg.body = World.GetInstance().GetGameObject(e.sponsorId).GetComponent<EventGenerator>().SelfSerialize(e.type,e.rawContent);
			content.msg.Add(msg);
			req.content = content;
			req.head = head;
			ret.Add(req);
        }
		return ret;
	}
开发者ID:windr00,项目名称:TestClient,代码行数:25,代码来源:DataOperator.cs

示例9: XRecv

        protected override bool XRecv(ref Msg msg)
        {
            bool isMessageAvailable;

            //  If we are in middle of sending a reply, we cannot receive next request.
            if (m_sendingReply)
                throw new FiniteStateMachineException("Rep.XRecv - cannot receive another request");

            //  First thing to do when receiving a request is to copy all the labels
            //  to the reply pipe.
            if (m_requestBegins)
            {
                while (true)
                {
                    isMessageAvailable = base.XRecv(ref msg);

                    if (!isMessageAvailable)
                        return false;

                    if (msg.HasMore)
                    {
                        //  Empty message part delimits the traceback stack.
                        bool bottom = (msg.Size == 0);

                        //  Push it to the reply pipe.
                        isMessageAvailable = base.XSend(ref msg);

                        if (!isMessageAvailable)
                            return false;

                        if (bottom)
                            break;
                    }
                    else
                    {
                        //  If the traceback stack is malformed, discard anything
                        //  already sent to pipe (we're at end of invalid message).
                        base.Rollback();
                    }
                }
                m_requestBegins = false;
            }

            //  Get next message part to return to the user.
            isMessageAvailable = base.XRecv(ref msg);

            if (!isMessageAvailable)
            {
                return false;
            }

            //  If whole request is read, flip the FSM to reply-sending state.
            if (!msg.HasMore)
            {
                m_sendingReply = true;
                m_requestBegins = true;
            }

            return true;
        }
开发者ID:bbqchickenrobot,项目名称:netmq,代码行数:60,代码来源:Rep.cs

示例10: Main

        private static int Main(string[] args)
        {
            if (args.Length != 3)
            {
                Console.WriteLine("usage: remote_thr <connect-to> <message-size> <message-count>");
                return 1;
            }

            string connectTo = args[0];
            int messageSize = int.Parse(args[1]);
            int messageCount = int.Parse(args[2]);

            using (var context = NetMQContext.Create())
            using (var push = context.CreatePushSocket())
            {
                push.Connect(connectTo);

                for (int i = 0; i != messageCount; i++)
                {
                    var message = new Msg();
                    message.InitPool(messageSize);
                    push.Send(ref message, SendReceiveOptions.None);
                    message.Close();
                }
            }

            return 0;
        }
开发者ID:bbqchickenrobot,项目名称:netmq,代码行数:28,代码来源:Program.cs

示例11: RegisterNewMessage

        /// <summary>
        /// Metoda pro registraci dalsich custom zprav
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="strRepresentation"></param>
        /// <returns></returns>
        public static bool RegisterNewMessage(Msg msg, string strRepresentation ) {
            if( KnownMessages.ContainsKey( msg ) )
                return false;
            else
                KnownMessages.Add( msg, strRepresentation );

            return true;
        }
开发者ID:jakubsuchybio,项目名称:MFF-Advanced-.NET,代码行数:14,代码来源:Message.cs

示例12: Flags

        public void Flags()
        {
            var msg = new Msg();

            Assert.AreEqual(MsgFlags.None, msg.Flags);

            msg.SetFlags(MsgFlags.Identity);

            Assert.IsTrue(msg.IsIdentity);
            Assert.IsFalse(msg.HasMore);
            Assert.IsFalse(msg.IsShared);
            Assert.AreEqual(MsgFlags.Identity, msg.Flags);

            msg.SetFlags(MsgFlags.More);

            Assert.IsTrue(msg.IsIdentity);
            Assert.IsTrue(msg.HasMore);
            Assert.IsFalse(msg.IsShared);
            Assert.AreEqual(MsgFlags.Identity | MsgFlags.More, msg.Flags);

            msg.SetFlags(MsgFlags.Shared);

            Assert.IsTrue(msg.IsIdentity);
            Assert.IsTrue(msg.HasMore);
            Assert.IsTrue(msg.IsShared);
            Assert.AreEqual(MsgFlags.Identity | MsgFlags.More | MsgFlags.Shared, msg.Flags);

            msg.SetFlags(MsgFlags.Identity);
            msg.SetFlags(MsgFlags.More);
            msg.SetFlags(MsgFlags.More);
            msg.SetFlags(MsgFlags.Shared);
            msg.SetFlags(MsgFlags.Shared);
            msg.SetFlags(MsgFlags.Shared);

            Assert.AreEqual(MsgFlags.Identity | MsgFlags.More | MsgFlags.Shared, msg.Flags);

            msg.ResetFlags(MsgFlags.Shared);

            Assert.IsTrue(msg.IsIdentity);
            Assert.IsTrue(msg.HasMore);
            Assert.IsFalse(msg.IsShared);
            Assert.AreEqual(MsgFlags.Identity | MsgFlags.More, msg.Flags);

            msg.ResetFlags(MsgFlags.More);

            Assert.IsTrue(msg.IsIdentity);
            Assert.IsFalse(msg.HasMore);
            Assert.IsFalse(msg.IsShared);
            Assert.AreEqual(MsgFlags.Identity, msg.Flags);

            msg.ResetFlags(MsgFlags.Identity);

            Assert.IsFalse(msg.IsIdentity);
            Assert.IsFalse(msg.HasMore);
            Assert.IsFalse(msg.IsShared);
            Assert.AreEqual(MsgFlags.None, msg.Flags);
        }
开发者ID:wangkai2014,项目名称:netmq,代码行数:57,代码来源:MsgTests.cs

示例13: CopyUninitialisedThrows

        public void CopyUninitialisedThrows()
        {
            var msg = new Msg();

            Assert.IsFalse(msg.IsInitialised);

            var msgCopy = new Msg();
            msgCopy.Copy(ref msg);
        }
开发者ID:wangkai2014,项目名称:netmq,代码行数:9,代码来源:MsgTests.cs

示例14: MessageReadySize

        public override bool MessageReadySize(int msgSize)
        {
            m_inProgress = new Msg();
            m_inProgress.InitPool(msgSize);

            NextStep(m_inProgress.Data, m_inProgress.Size, RawMessageReadyState);

            return true;
        }
开发者ID:wangkai2014,项目名称:netmq,代码行数:9,代码来源:RawDecoder.cs

示例15: OnGUI

	void OnGUI(){
		GUI.TextArea (new Rect (10, 10, 500, 400), show_str);
		modelId =GUI.TextField (new Rect (520, 10, 80, 30), modelId);
		actionId=GUI.TextField (new Rect (600, 10, 80, 30), actionId);
		msg =GUI.TextField (new Rect (520, 50, 160, 30), msg);
		if (GUI.Button (new Rect (690, 10, 160, 30), "ADD_STR")) {
			
		}
		if (GUI.Button (new Rect (690, 50, 160, 30), "SEND")) {
			string str =  modelId + "-" + actionId + " data =" + msg;

            string statc = "0,0,'538642', '1', '10002', '1', 99000000, 999999";
			Msg data = new Msg ();
			data.Write (1);
			//data.Write ('a');
			//data.Write ((byte)1.1f);
			//data.Write(11);
			data.Write (2L);


			byte[] b = data.Buffer;

			bool a0 = data.ReadBoolean ();
			//char a1 = (char)data.ReadByte ();
			long a2 = data.ReadInt64 ();
			//float a2 = float.Parse(data.ReadBytes (sizeof(float)));
			Debug.Log ("=sum length=="+(sizeof(int)+sizeof(long))+"============byte array===" + data.Length);
			Debug.Log ("=======a0=" + a0);
			//Debug.Log ("=======a1=" + a1);
			Debug.Log ("=======a2=" + a2);
			//Debug.Log ("encode code==================="+code);

            AppendShowString(str);

		}
        if (GUI.Button(new Rect(690, 90, 160, 30), "connect")) {
            try { 
                network.connectServer();
                AppendShowString("connect to server");
            }
            catch (Exception e) {
                AppendShowString(e.ToString());
            }
		}
		if (GUI.Button(new Rect(690,130,160,30),"disconnect")){
            try
            {
                network.closeConnection();
                AppendShowString("disconnect server");
            }catch(Exception e)
            {
                AppendShowString(e.ToString());
            }
			
		}

	}
开发者ID:ZhHong,项目名称:u3d_client,代码行数:57,代码来源:Main.cs


注:本文中的Msg类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。