Ejemplo n.º 1
0
        protected void m_prcClient_PacketSent(FrostbiteConnection sender, bool isHandled, Packet packetBeforeDispatch) {
            if (LogDebugDetails == true) {
                if (packetBeforeDispatch.OriginatedFromServer == false) {
                    Write(GetDebugPacket("^6Client", "^2", packetBeforeDispatch, null));
                }
                else {
                    if (LogEventsConnection == true) {
                        Write(GetDebugPacket("^8Server", "^2", packetBeforeDispatch, null));
                    }
                }
            }
            else {
                if (packetBeforeDispatch.OriginatedFromServer == false || LogEventsConnection == true) {
                    Write("^b^2{0}", packetBeforeDispatch.ToString().TrimEnd('\r', '\n'));
                }
            }

            BytesSent += packetBeforeDispatch.PacketSize;
        }
Ejemplo n.º 2
0
        protected static string GetDebugPacket(string connectionPrefix, string packetColour, Packet packet, Packet requestPacket) {
            string debugString = String.Empty;

            try {
                debugString = string.Format("{0,10}: {1,-12} S: {2,-6} {3}{4}", connectionPrefix, GetRequestResponseColour(packet), packet.SequenceNumber, packetColour, packet.ToDebugString().Replace("\r", "").Replace("\n", ""));

                if (requestPacket != null) {
                    debugString = String.Format("{0} ^0(RE: ^2{1}^0)", debugString, requestPacket.ToDebugString().TrimEnd('\r', '\n'));
                }

                debugString = debugString.Replace("{", "{{").Replace("}", "}}");
            }
            catch (Exception e) {
                FrostbiteConnection.LogError(String.Join(", ", new[] { connectionPrefix, packetColour, packet.ToString(), requestPacket != null ? requestPacket.ToString() : "" }), "", e);
                debugString = "";
            }

            return debugString;
        }
Ejemplo n.º 3
0
        private void m_prcClient_PacketRecieved(FrostbiteConnection sender, bool isHandled, Packet packetBeforeDispatch) {
            Packet cpRequestPacket = Client.Game.Connection.GetRequestPacket(packetBeforeDispatch);

            if (packetBeforeDispatch.OriginatedFromServer == false && packetBeforeDispatch.IsResponse == true) {
                if (LogDebugDetails == true && cpRequestPacket != null) {
                    if (cpRequestPacket.OriginatedFromServer == false) {
                        Write(GetDebugPacket("^6Client", "^4", packetBeforeDispatch, cpRequestPacket));
                    }
                    else {
                        if (LogEventsConnection == true) {
                            Write(GetDebugPacket("^8Server", "^4", packetBeforeDispatch, cpRequestPacket));
                        }
                    }
                }
                else {
                    if ((cpRequestPacket != null && cpRequestPacket.OriginatedFromServer == false) || LogEventsConnection == true) {
                        Write("^b^4{0}", packetBeforeDispatch.ToString().TrimEnd('\r', '\n').Replace("{", "{{").Replace("}", "}}"));
                    }
                }
            }
                // ELSE IF it's an event initiated by the server (OnJoin, OnLeave, OnChat etc)
            else if (packetBeforeDispatch.OriginatedFromServer == true && packetBeforeDispatch.IsResponse == false) {
                if (LogDebugDetails == true) {
                    if (cpRequestPacket != null && cpRequestPacket.OriginatedFromServer == false) {
                        Write(GetDebugPacket("^6Client", "^4", packetBeforeDispatch, null));
                    }
                    else {
                        if (LogEventsConnection == true) {
                            Write(GetDebugPacket("^8Server", "^4", packetBeforeDispatch, null));
                        }
                    }
                }
                else {
                    if ((cpRequestPacket != null && cpRequestPacket.OriginatedFromServer == false) || LogEventsConnection == true) {
                        Write("^b^4{0}", packetBeforeDispatch.ToString().TrimEnd('\r', '\n').Replace("{", "{{").Replace("}", "}}"));
                    }
                }
            }

            BytesRecieved += packetBeforeDispatch.PacketSize;
        }