public int Send(Chat_Model_Base model, Type type, int to_id, bool promise = true, Func <Coop_Model_ACK, bool> onReceiveAck = null, Func <Coop_Model_Base, bool> onPreResend = null) { int result = 0; ChatPacket chatPacket = new ChatPacket(); ChatPacketHeader chatPacketHeader2 = chatPacket.header = new ChatPacketHeader(0, model.commandId, fromId); chatPacket.model = model; PacketStream stream = chatPacket.Serialize(); if (model.commandId == 502) { goto IL_0040; } goto IL_0040; IL_0040: NativeSend(stream); return(result); }
private void OnChatInput(string input) { if (!string.IsNullOrEmpty(input) && !string.IsNullOrWhiteSpace(input)) { var chat = new ChatPacket() { author = _clientNickname, entry = input }; var msg = new Message() { header = "chat", packet = chat.Serialize() }; _client.Send(msg.Serialize()); _chatPanel.inputField.text = ""; _chatPanel.inputField.ActivateInputField(); } }
private void Logout() { try { if (_clientSocket != null) { // Initialize a packet object to store the data to be sent. var sendData = new ChatPacket() { ChatDataIdentifier = DataIdentifier.LogOut, ChatName = _chatName, ChatMessage = null }; // Get packet as byte array. var data = sendData.Serialize(); // Send packet to the server. _clientSocket.SendTo(data, 0, data.Length, SocketFlags.None, _serverEndPoint); } } catch (Exception ex) { Logger.WriteLine("Logout error!"); Logger.WriteLine(ex.Message); } finally { // Close the socket. _clientSocket.Close(); _clientSocket = null; } }