private void OnCancel(object sender, EventArgs args) { try { switch (type) { case MessageType.Discard: promptPageState.OnExit(); break; default: if (type.Equals(MessageType.Gps)) { locationPageState.OnLocationIgnored(); } break; } Task.Run(async() => await PopupNavigation.Instance.RemovePageAsync(this)); } catch (Exception ex) { //DisplayAlert("Error", ex.Message); Debug.WriteLine($"Exception after Selection Complete: {ex}"); } }
public void SendMqMessage <TPropery>(MessageType messageType, string strText, List <TPropery> lstProperty) where TPropery : Property { try { IMessage msg; if (messageType.Equals(MessageType.Text)) { msg = producer.CreateTextMessage(); ((ITextMessage)msg).Text = strText; } else { msg = producer.CreateBytesMessage(); ((IBytesMessage)msg).Content = Encoding.Default.GetBytes(strText); } foreach (Property prop in lstProperty) { msg.Properties.SetString(prop.name, prop.value); } producer.Send(msg, Apache.NMS.MsgDeliveryMode.NonPersistent, Apache.NMS.MsgPriority.Normal, TimeSpan.MinValue); } catch (System.Exception ex) { } }
public String FormatMessage(String msg, MessageType type) { String prefix = "[^b" + GetPluginName() + "^n] "; if (type.Equals(MessageType.Warning)) { prefix += "^1^bWARNING^0^n: "; } else if (type.Equals(MessageType.Error)) { prefix += "^1^bERROR^0^n: "; } else if (type.Equals(MessageType.Exception)) { prefix += "^1^bEXCEPTION^0^n: "; } return(prefix + msg); }
public String FormatMessage(String msg, MessageType type) { String prefix = "[^bBFJC_SkillLimiter^n] "; if (type.Equals(MessageType.Warning)) { prefix += "^1^bWARNING^0^n: "; } else if (type.Equals(MessageType.Error)) { prefix += "^1^bERROR^0^n: "; } else if (type.Equals(MessageType.Exception)) { prefix += "^1^bEXCEPTION^0^n: "; } return(prefix + msg); }
public override bool Equals(object obj) { bool equals = false; MessageKey compare = obj as MessageKey; if (compare != null) { equals = (type.Equals(compare.type) && code.Equals(compare.code)); } return(equals); }
public MessageText(string text, MessageType type, int timeToDestroy) { GameObject mt = MonoBehaviour.Instantiate(theGameObject); if (type.Equals(MessageType.Error)) { mt.GetComponentInChildren <Text>().color = Color.red; } else if (type.Equals(MessageType.OK)) { mt.GetComponentInChildren <Text>().color = Color.green; } else { mt.GetComponentInChildren <Text>().color = Color.black; } mt.GetComponentInChildren <Text>().text = text; MonoBehaviour.Destroy(mt, timeToDestroy); }
public String FormatMessage(String msg, MessageType type) { String prefix = "[^bBF4DB] "; if (type.Equals(MessageType.Success)) { prefix += "^2Success: "; } else if (type.Equals(MessageType.Warning)) { prefix += "^1WARNING: "; } else if (type.Equals(MessageType.Error)) { prefix += "^1ERROR: "; } else if (type.Equals(MessageType.Exception)) { prefix += "^1EXCEPTION: "; } return(prefix + msg); }
public string GetMessage() { StringBuilder sb = new StringBuilder(); if (InitiatorType != InitiatorType.Unknown) { sb.Append(InitiatorType.Equals(InitiatorType.Client) ? Resources.Client : Resources.Server); } if (!MessageType.Equals(MessageType.Default)) { sb.Append(string.Format(Resources.Template_MessageType, MessageType.Equals(MessageType.Send) ? Resources.MessageSended : Resources.MessageRecieved)); } sb.Append(Message); return(sb.ToString()); }
//{ // get;set; //} public void consumer_listener(IMessage message) { string strMsg; if (messageType.Equals(MessageType.Text)) { ITextMessage msg = (ITextMessage)message; strMsg = msg.Text; } else { IBytesMessage msg = (IBytesMessage)message; strMsg = Encoding.Default.GetString(msg.Content); } Console.Write(strMsg); }
protected Boolean CheckType(MessageType expectedMessageType, MessageType actualMessageType) { Boolean success = expectedMessageType.Equals(actualMessageType); if (!success) { AppendReason(String.Format("Expected type {0}, but received {1}", expectedMessageType, actualMessageType)); RowItem bi = new RowItem(); bi.Name = "type"; bi.ErrorInfo = String.Format("Expected type {0}, but received {1}", expectedMessageType, actualMessageType); bi.Expected = expectedMessageType.ToString(); bi.Received = actualMessageType.ToString(); bi.Parent = null; bi.IsPassed = false; AppendBaseItem(bi); } return(success); }
private static async Task <IUICommand> DisplayMessageAsync(string message, MessageType messageType, UICommandInvokedHandler handler) { MessageDialog dialog = null; if (messageType.Equals(MessageType.ErrorMessage)) { dialog = new MessageDialog(message, "Error"); } else { dialog = new MessageDialog(message, "Information"); } if (handler != null) { dialog.Commands.Add(new UICommand("Close", handler)); } return(await dialog.ShowAsync()); }
private void btnSend_Click(object sender, EventArgs e) { string msg = txtMsg.Text.Trim(); if (messageType.Equals(MessageType.File)) { if (!string.IsNullOrEmpty(msg)) { messageType = MessageType.MessageAndFile; } } else { if (string.IsNullOrEmpty(msg)) { MessageBox.Show("消息不能为空!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } txtMsg.Text = ""; DataStructure data = new DataStructure { DateTime = DateTime.Now, UserStatus = UserStatus.Send, MessageType = messageType, File = uploadFile, Message = msg, UserName = txtUserName.Text.Trim() }; Task task = new Task(() => { SendAndReceiveMsg(data); }); task.Start(); }
/* ======================== SUPPORT FUNCTIONS ============================= */ private String FormatMessage(String msg, MessageType type, int level) { String prefix = "[^b" + GetPluginName() + "^n]:" + level + " "; if (Thread.CurrentThread.Name != null) prefix += "Thread(^b^5" + Thread.CurrentThread.Name + "^0^n): "; if (type.Equals(MessageType.Warning)) prefix += "^1^bWARNING^0^n: "; else if (type.Equals(MessageType.Error)) prefix += "^1^bERROR^0^n: "; else if (type.Equals(MessageType.Exception)) prefix += "^1^bEXCEPTION^0^n: "; else if (type.Equals(MessageType.Debug)) prefix += "^9^bDEBUG^n: "; return prefix + msg; }
private static void ReadXml() { bool deleteFile = false; int id = 0; string sender = null; string receiver = null; MessageType type = MessageType.Unknown; string messageStored = null; DateTime date = new DateTime(); DateTime deletionDate = new DateTime(); // Create an XML reader for this file. using (XmlReader reader = XmlReader.Create("MessageLog.xml")) { reader.MoveToContent(); while (reader.Read()) { // Only detect start elements. if (reader.NodeType == XmlNodeType.Element) { // Get element name and switch on it. switch (reader.Name) { case "ID": if (reader.Read()) { id = int.Parse(reader.Value.Trim()); } break; case "Sender": if (reader.Read()) { sender = DecryptString(reader.Value.Trim(), initVector); } break; case "Receiver": if (reader.Read()) { receiver = DecryptString(reader.Value.Trim(), initVector); } break; case "MessageType": if (reader.Read()) { string obj = reader.Value.Trim(); type = (MessageType)Enum.Parse(typeof(MessageType), obj, true); } break; case "MessageStored": if (reader.Read()) { messageStored = DecryptString(reader.Value.Trim(), initVector); } break; case "Date": if (reader.Read()) { date = DateTime.Parse(reader.Value.ToString().Trim()); } break; case "DeletionDate": if (reader.Read()) { deletionDate = DateTime.Parse(reader.Value.ToString().Trim()); } break; } } else if (reader.NodeType == XmlNodeType.EndElement) { DateTime localDate = DateTime.Now; if (localDate.Date <= deletionDate.Date || type.Equals(MessageType.Important)) { switch (reader.Name) { case "Message": if (reader.Read()) { storedMessages.Add(new Message() { Sender = sender, Receiver = receiver, MessageToStore = messageStored, MessageType = type, Date = date, DeletionDate = deletionDate }); } break; } } } } } }
/// <summary> /// Get all messages of current user. /// </summary> /// <param name="userID">Sender user idetifier.</param> /// <param name="type">Type of message.</param> /// <param name="selectType">Type of message selecting.</param> /// <returns>List of user messages.</returns> public static IEnumerable<Message> GetUserMessages( Guid userID, MessageType type, MessageSelectType selectType) { IEnumerable<Message> recordList = null; using (SocialNetworkDBEntities record = new SocialNetworkDBEntities()) { if (type.Equals(MessageType.Posted)) { switch (selectType) { case MessageSelectType.All: { recordList = record.Messages .Where(w => w.FromID == userID && !w.IsDeletedBySender) .OrderByDescending(o => o.SendDate) .Select(s => new Message { MessageID = s.MessageID, FromID = s.FromID, ToID = s.ToID, SendDate = s.SendDate, Header = s.Header, Text = s.Text, Status = s.Status, IsDeletedBySender = s.IsDeletedBySender, IsDeletedByReceiver = s.IsDeletedByReceiver }) .ToList(); } break; case MessageSelectType.OnlyNew: { } break; case MessageSelectType.OnlyOld: { } break; } } else { switch (selectType) { case MessageSelectType.All: { recordList = record.Messages .Where(w => w.ToID == userID && !w.IsDeletedByReceiver) .OrderByDescending(o => o.SendDate) .Select(s => new Message { MessageID = s.MessageID, FromID = s.FromID, ToID = s.ToID, SendDate = s.SendDate, Header = s.Header, Text = s.Text, Status = s.Status, IsDeletedBySender = s.IsDeletedBySender, IsDeletedByReceiver = s.IsDeletedByReceiver }) .ToList(); } break; case MessageSelectType.OnlyNew: { } break; case MessageSelectType.OnlyOld: { } break; } } } return recordList; }
private void GetMessageCallback(IAsyncResult asynchronousResult) { try { HttpWebRequest webRequest = (HttpWebRequest)asynchronousResult.AsyncState; HttpWebResponse response; // End the get response operation response = (HttpWebResponse)webRequest.EndGetResponse(asynchronousResult); if (!MessageType.Equals("visitor")) { response.Headers[HttpRequestHeader.ContentType] = "application/json; charset=UTF-8"; } Stream streamResponse = response.GetResponseStream(); StreamReader streamReader = new StreamReader(streamResponse); var Response = streamReader.ReadToEnd(); if (MessageType.Equals("visitor")) { Match mc = Regex.Match(Response, "<script id=\"data_visitorList\" type=\"application/json\">(.|\n)*?</script>", RegexOptions.IgnoreCase); if (mc.Success) { Response = mc.Value.Replace("<script id=\"data_visitorList\" type=\"application/json\">", "").Replace("</script>", ""); } else { Response = "{list:[],page:{pageCount:0,pageNo:0}}"; } } dynamic json = JsonConvert.DeserializeObject(Response); MessageListCollection = new ObservableCollection <Message>(); foreach (var item in json["list"]) { var message = new Message(); message.ID = Convert.ToString(item["id"]); message.User = new User(); message.User.ID = Convert.ToString(item["user"]["id"]); message.User.Avatar = (string)(item["user"]["avatar"]); message.User.NickName = Convert.ToString(item["user"]["nickName"]); message.User.Sex = ("人妖,他,她").Split(',')[(int)item["user"]["sex"]]; message.User.Height = (string)item["user"]["height"]; if (item["user"]["education"] != null) { message.User.Education = AppGlobalStatic.Xueli[int.Parse((string)item["user"]["education"])]; } message.User.Url = Convert.ToString(item["user"]["url"]); message.User.Age = Convert.ToString(item["user"]["age"]) + " " + Love.Resources.AppGlobalStatic.AgeToAnimal((string)item["user"]["age"]); message.Type = (string)item["type"]; switch (MessageType) { case "visitor": message.RichContent = message.User.Sex + "来看过你"; message.PrettyTime = AppGlobalStatic.DateStringFromNow(((string)item["visitTime"]).Replace("今天", DateTime.Now.ToString("yyyy-MM-dd"))); message.Source = message.User.Age + " " + message.User.Height + " " + message.User.Education; break; case "heed": message.RichContent = (string)item["content"]; message.PrettyTime = AppGlobalStatic.DateStringFromNow(((string)item["followTime"]).Replace("今天", DateTime.Now.ToString("yyyy-MM-dd"))); message.Source = message.User.Age + " " + message.User.Height + " " + message.User.Education;// + " " + message.User.Sex + "收藏了你"; break; case "digg": message.RichContent = (string)item["richContent"]; message.PrettyTime = AppGlobalStatic.DateStringFromNow(((string)item["praiseTime"]).Replace("今天", DateTime.Now.ToString("yyyy-MM-dd"))); message.Source = message.User.Age + " " + message.User.Height + " " + message.User.Education;//message.User.Sex + " 赞了你"; break; } MessageListCollection.Add(message); } int pageCount = (int)json["page"]["pageCount"]; int pageNo = (int)json["page"]["pageNo"]; if (!MessageType.Equals("visitor")) { if (MessageListCollection.Count > 0) { if (pageCount != pageNo) { MessageListCollection.Add(new Message() { IsMoreButtonTrend = true }); } } } PageIndex_Message++; Dispatcher.BeginInvoke(() => { list_message.ItemsSource = MessageListCollection; }); streamResponse.Close(); streamReader.Close(); response.Close(); } catch (WebException e) { } Dispatcher.BeginInvoke(() => { progressBar1.IsIndeterminate = false; ApplicationBar.Mode = ApplicationBarMode.Default; }); }
public override bool Equals(object obj) => MessageType.Equals(obj);
protected bool Equals(CacheKey other) { return(MessageType.Equals(other.MessageType) && WrapperType.Equals(other.WrapperType)); }
/// <summary> /// Get all messages of current user. /// </summary> /// <param name="userID">Sender user idetifier.</param> /// <param name="type">Type of message.</param> /// <param name="selectType">Type of message selecting.</param> /// <returns>List of user messages.</returns> public static IEnumerable <Message> GetUserMessages( Guid userID, MessageType type, MessageSelectType selectType) { IEnumerable <Message> recordList = null; using (SocialNetworkDBEntities record = new SocialNetworkDBEntities()) { if (type.Equals(MessageType.Posted)) { switch (selectType) { case MessageSelectType.All: { recordList = record.Messages .Where(w => w.FromID == userID && !w.IsDeletedBySender) .OrderByDescending(o => o.SendDate) .Select(s => new Message { MessageID = s.MessageID, FromID = s.FromID, ToID = s.ToID, SendDate = s.SendDate, Header = s.Header, Text = s.Text, Status = s.Status, IsDeletedBySender = s.IsDeletedBySender, IsDeletedByReceiver = s.IsDeletedByReceiver }) .ToList(); } break; case MessageSelectType.OnlyNew: { } break; case MessageSelectType.OnlyOld: { } break; } } else { switch (selectType) { case MessageSelectType.All: { recordList = record.Messages .Where(w => w.ToID == userID && !w.IsDeletedByReceiver) .OrderByDescending(o => o.SendDate) .Select(s => new Message { MessageID = s.MessageID, FromID = s.FromID, ToID = s.ToID, SendDate = s.SendDate, Header = s.Header, Text = s.Text, Status = s.Status, IsDeletedBySender = s.IsDeletedBySender, IsDeletedByReceiver = s.IsDeletedByReceiver }) .ToList(); } break; case MessageSelectType.OnlyNew: { } break; case MessageSelectType.OnlyOld: { } break; } } } return(recordList); }
private static void RunLoop() { NetEventType eventType; do { eventType = Transport.Poll(out ulong connectionId, out byte channelId, out ArraySegment <byte> payload); switch (@eventType) { case NetEventType.Data: { // Last byte is the messageType MessageType messageType = (MessageType)payload.Array [payload.Offset + payload.Count - 1]; if (!messageType.Equals(MessageType.Data)) { if (Config.EnableRuntimeMetaLogging) { Console.WriteLine(string.Format("[INFO] messageType ({0})", messageType.ToString())); } } switch (messageType) { case MessageType.StartServer: { // Resolve the endpoint IPEndPoint endpoint = Transport.GetEndPoint(connectionId); if (Config.EnableRuntimeMetaLogging) { Console.WriteLine(string.Format("[INFO] Resolved endpoint ({0})", endpoint)); } // Check if they are already connected or perhaps are already hosting, if so return if (HasPeer(connectionId) || ServerAddressToRoom.ContainsKey(endpoint)) { if (Config.EnableRuntimeMetaLogging) { Console.WriteLine("[ERROR] Client is already connected Or perhaps are already hosting"); } return; } // Create the client Client client = new Client() { ConnectionId = connectionId, IsServer = true, OutgoingBytes = 0, ConnectTime = DateTime.UtcNow }; // Create the room Room room = new Room(client); // Add the room Rooms.Add(room); if (Config.EnableRuntimeMetaLogging) { Console.WriteLine(string.Format("[INFO] Room created: room.RoomId ({0}) room.Server.ConnectionId ({1}) room.Server.ConnectTime ({2})", room.RoomId, room.Server.ConnectionId, room.Server.ConnectTime)); } if (endpoint != null) { // Make address IPv6 endpoint = new IPEndPoint(endpoint.Address.MapToIPv6(), endpoint.Port); ServerAddressToRoom.Add(endpoint, room); if (Config.EnableRuntimeMetaLogging) { Console.WriteLine("[INFO] Server started from " + endpoint); } } else { if (Config.EnableRuntimeMetaLogging) { Console.WriteLine(string.Format("[ERROR] Server failed to start: endpoint ({0})", endpoint)); } } byte [] ipv6AddressBuffer; IPAddress ipAddress = endpoint.Address; if (Config.EnableRuntimeMetaLogging) { Console.WriteLine(string.Format("[INFO] endpoint.Address.AddressFamily ({0})", endpoint.Address.AddressFamily.ToString())); } if (ipAddress.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6) { ipv6AddressBuffer = ipAddress.GetAddressBytes(); } else if (ipAddress.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { byte [] ipv4Address = ipAddress.GetAddressBytes(); ipv6AddressBuffer = new byte [16] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, ipv4Address [0], ipv4Address [1], ipv4Address [2], ipv4Address [3] }; } else { // TODO: Throw wrong type ipv6AddressBuffer = null; } // TODO: Throw if address is not 16 bytes. It should always be // Write the address for (int i = 0; i < ipv6AddressBuffer.Length; i++) { MESSAGE_BUFFER [i] = ipv6AddressBuffer [i]; } // Write the port for (byte i = 0; i < sizeof(ushort); i++) { MESSAGE_BUFFER [16 + i] = ((byte)(endpoint.Port >> (i * 8))); } // Write the message type MESSAGE_BUFFER [18] = (byte)MessageType.AddressReport; // Send connect to client Transport.Send(new ArraySegment <byte> (MESSAGE_BUFFER, 0, 19), DEFAULT_CHANNEL_BYTE, connectionId); if (Config.EnableRuntimeMetaLogging) { Console.WriteLine("[INFO] Sending address report"); } } break; case MessageType.ConnectToServer: { // Resolve the endpoint IPEndPoint endpoint = Transport.GetEndPoint(connectionId); if (Config.EnableRuntimeMetaLogging) { Console.WriteLine(string.Format("[INFO] Resolved endpoint ({0})", endpoint)); } // Check if they are already connected or perhaps are already hosting, if so return if (HasPeer(connectionId) || ServerAddressToRoom.ContainsKey(endpoint)) { if (Config.EnableRuntimeMetaLogging) { Console.WriteLine("[ERROR] Client is already connected Or perhaps are already hosting"); } return; } if (payload.Count < 1 + 2 + 16) { if (Config.EnableRuntimeMetaLogging) { Console.WriteLine(string.Format("[ERROR] Invalid payload size ({0})", 1 + 2 + 16)); } // Invalid size return; } // 1 for messageType, 2 for port, 16 for address int addressOffset = payload.Count - (1 + 2 + 16); // 1 for messageType, 2 for port int portOffset = payload.Count - (1 + 2); // Copy the address for (int i = 0; i < 16; i++) { ADDRESS_BYTE_ARRAY [i] = payload.Array [payload.Offset + addressOffset + i]; } // Read port ushort port = (ushort)(((ushort)payload.Array [payload.Offset + portOffset]) | ((ushort)payload.Array [payload.Offset + portOffset + 1] << 8)); // Parse address IPAddress address = new IPAddress(ADDRESS_BYTE_ARRAY); // Create endpoint endpoint = new IPEndPoint(address, port); if (Config.EnableRuntimeMetaLogging) { Console.WriteLine("[INFO] Connection requested to address " + endpoint); } if (ServerAddressToRoom.ContainsKey(endpoint)) { if (Config.EnableRuntimeMetaLogging) { Console.WriteLine(string.Format("[INFO] Connection approved: endpoint ({0})", endpoint)); } // Get the room they want to join Room room = ServerAddressToRoom [endpoint]; // Create a client for them Client client = new Client() { ConnectionId = connectionId, IsServer = false, ConnectTime = DateTime.UtcNow, OutgoingBytes = 0 }; // Handle the connect room.HandleClientConnect(client); } else { if (Config.EnableRuntimeMetaLogging) { Console.WriteLine(string.Format("[ERROR] Connection disproved: endpoint ({0})", endpoint)); } } } break; case MessageType.Data: { foreach (Room room in Rooms) { if (room.HasPeer(connectionId, out bool isServer)) { // Found a matching client in room if (isServer) { // The server is sending data ulong destination = (((ulong)payload.Array [payload.Offset + payload.Count - 9]) | ((ulong)payload.Array [payload.Offset + payload.Count - 8] << 8) | ((ulong)payload.Array [payload.Offset + payload.Count - 7] << 16) | ((ulong)payload.Array [payload.Offset + payload.Count - 6] << 24) | ((ulong)payload.Array [payload.Offset + payload.Count - 5] << 32) | ((ulong)payload.Array [payload.Offset + payload.Count - 4] << 40) | ((ulong)payload.Array [payload.Offset + payload.Count - 3] << 48) | ((ulong)payload.Array [payload.Offset + payload.Count - 2] << 56)); // Safety check. Make sure who they want to send to ACTUALLY belongs to their room if (room.HasPeer(destination, out isServer) && !isServer) { // We strip the connectionId. Since this is from the server, a source is not needed. payload.Array [payload.Offset + payload.Count - 9] = (byte)MessageType.Data; // [data, data, data, dest1, dest2, dest3, dest4, dest5, dest6, dest7, dest8, mtype_r, none, none, none] => [{data, data, data, mtype_s}, dest2, dest3, dest4, dest5, dest6, dest7, dest8, mtype_r, none, none, none] // Send a shrunk version of the array. room.Send(destination, connectionId, channelId, new ArraySegment <byte> (payload.Array, payload.Offset, payload.Count - 8)); } } else { // A client is sending data int writeOffset = 0; byte [] buffer = null; if (payload.Array.Length < payload.Count + sizeof(ulong)) { if (Program.MESSAGE_BUFFER.Length < payload.Count + sizeof(ulong)) { // Message buffer cannot fit the payload either. // Check if we can alloc temporary memory if (Config.AllowTemporaryAlloc && Config.MaxTemporaryAlloc >= payload.Count + sizeof(ulong)) { // We are allowed to alloc this amount! // Alloc a large enough buffer writeOffset = 0; buffer = new byte [payload.Count + sizeof(ulong)]; } } else { // Message buffer can store it! writeOffset = 0; buffer = Program.MESSAGE_BUFFER; } if (buffer != null) { // We have something alloced. Lets copy the current payload! Buffer.BlockCopy(payload.Array, payload.Offset, buffer, writeOffset, payload.Count); } } else { buffer = payload.Array; writeOffset = payload.Offset; } if (buffer != null) { // Write the connectionId at the end of the recieved message (because optimization) // We use -1 because we actually want to overwrite the last byte in the message, since that is the old messageType location. It will be moved forward now. for (byte i = 0; i < sizeof(ulong); i++) { buffer [writeOffset + payload.Count - 1 + i] = ((byte)(connectionId >> (i * 8))); } // Write the message type at the new end buffer [writeOffset + payload.Count + 7] = (byte)MessageType.Data; // Send the expanded array room.Send(room.ServerConnectionId, connectionId, channelId, new ArraySegment <byte> (payload.Array, payload.Offset, payload.Count + sizeof(ulong))); } else { // Message is too large. Drop it } } // Exit loop when room is found break; } } } break; case MessageType.ClientDisconnect: { ulong clientConnectionId = (((ulong)payload.Array [payload.Offset]) | ((ulong)payload.Array [payload.Offset + 1] << 8) | ((ulong)payload.Array [payload.Offset + 2] << 16) | ((ulong)payload.Array [payload.Offset + 3] << 24) | ((ulong)payload.Array [payload.Offset + 4] << 32) | ((ulong)payload.Array [payload.Offset + 5] << 40) | ((ulong)payload.Array [payload.Offset + 6] << 48) | ((ulong)payload.Array [payload.Offset + 7] << 56)); if (Config.EnableRuntimeMetaLogging) { Console.WriteLine("[INFO] Client disconnect request"); } foreach (Room room in Rooms) { if (room.ServerConnectionId == connectionId && room.HandleClientDisconnect(clientConnectionId, true)) { // Only disconnect one. A peer can only be in 1 room break; } } } break; } } break; case NetEventType.Disconnect: { if (Config.EnableRuntimeMetaLogging) { Console.WriteLine("[INFO] Peer disconnected"); } foreach (Room room in Rooms) { if (room.HandleClientDisconnect(connectionId)) { // Each connection can only have 1 room break; } } } break; } }while (eventType != NetEventType.Nothing); }
public String FormatMessage(String msg, MessageType type) { String prefix = "[^b" + GetPluginName() + "^n] "; if (type.Equals(MessageType.Warning)) prefix += "^1^bWARNING^0^n: "; else if (type.Equals(MessageType.Error)) prefix += "^1^bERROR^0^n: "; else if (type.Equals(MessageType.Exception)) prefix += "^1^bEXCEPTION^0^n: "; return prefix + msg; }
/****** 获取菜单点击的信息 **************/ private MenuEventLog GetMenuEventLogModel(MessageType msgType) { MenuEventLog menuLog = new MenuEventLog(); var root = doc.DocumentElement; menuLog.FromUserName = root.SelectSingleNode("FromUserName").InnerText; menuLog.clickTime = FormatTime(root.SelectSingleNode("CreateTime").InnerText); string menuKey = root.SelectSingleNode("EventKey").InnerText; if (msgType.Equals(MessageType.EventView)) { int index = menuKey.IndexOf("="); int endIndex = menuKey.IndexOf("&"); if (endIndex > index) menuKey = menuKey.Substring(index + 1, endIndex - index - 1); } menuLog.menuId = menuKey; return menuLog; }