private PyObject OldHandle(PyObject packet) { // Check for login packets and just forward them if (packet is PyTuple) { // Those are the first packets, sent by both client and server return(packet); } else if (packet is PyInt) { // This is only sent by the server return(packet); } else if (packet is PyString) { // This is only sent by the server return(packet); } else if (packet is PyDict) { // Packet sent by the client(HandshakeAck) // We need to modify it in order to put our own client address, as it isnt the same as the address that the server sends PyDict handshake = packet as PyDict; PyDict session = handshake.Get("session_init") as PyDict; session.Set("address", new PyString(socket.GetAddress())); handshake.Set("session_init", session); return(handshake); } else if (packet is PyObjectEx) // Exceptions... just check the type and decide what to do { PyException exception = new PyException(); if (exception.Decode(packet) == true) // Ignore the error { Log.Debug("Exceptions", "Got exception of type " + exception.exception_type); } return(packet); } else // Normal packets { PyPacket p = new PyPacket(); if (p.Decode(packet) == false) { // Big problem here, we dont know who to send this Log.Error("Client", "Cannot decode PyPacket"); } else { return(HandlePyPacket(p)); } return(packet); } }
private static PyObject HandleObject(PyObjectEx dat, Connection connection) { // Only exceptions should be this type PyException ex = new PyException(); if (ex.Decode(dat) == false) { Log.Error("Connection", "Unhandled PyObjectEx packet"); return(null); } Log.Error("Connection", "Got an exception packet of type: " + ex.exception_type + ". " + ex.message); return(null); }
private void DisplayPythonError(PyException e) { if (_editor != null && !_editor.IsDisposed) { if (e != null) { _editor.BeginInvoke(new Action(() => { _editor.SetError(e.Message, e.Line > 0 ? e.Line - 1 : e.Line, e.Offset); })); } else { _editor.BeginInvoke(new Action(() => { _editor.ClearError(); })); } } }
private PyObject OldHandle(PyObject packet) { // Check for login packets and just forward them if (packet is PyTuple) { // Those are the first packets, sent by both client and server return packet; } else if (packet is PyInt) { // This is only sent by the server return packet; } else if (packet is PyString) { // This is only sent by the server return packet; } else if (packet is PyDict) { // Packet sent by the client(HandshakeAck) // We need to modify it in order to put our own client address, as it isnt the same as the address that the server sends PyDict handshake = packet as PyDict; PyDict session = handshake.Get("session_init") as PyDict; session.Set("address", new PyString(socket.GetAddress())); handshake.Set("session_init", session); return handshake; } else if (packet is PyObjectEx) // Exceptions... just check the type and decide what to do { PyException exception = new PyException(); if (exception.Decode(packet) == true) // Ignore the error { Log.Debug("Exceptions", "Got exception of type " + exception.exception_type); } return packet; } else // Normal packets { PyPacket p = new PyPacket(); if (p.Decode(packet) == false) { // Big problem here, we dont know who to send this Log.Error("Client", "Cannot decode PyPacket"); } else { return HandlePyPacket(p); } return packet; } }