public override uint Send(Message msg) { if (!isConnected) { return(0); } /* * if (msg.Header.MessageType == NDesk.DBus.MessageType.Signal) { * Signal signal = new Signal (msg); * if (signal.Member == "NameAcquired" || signal.Member == "NameLost") { * string dest = (string)msg.Header[FieldCode.Destination]; * if (dest != UniqueName) * return 0; * } * } */ if (msg.Header.MessageType != NDesk.DBus.MessageType.MethodReturn) { msg.Header[FieldCode.Sender] = ServerBus.DBusBusName; } if (UniqueName != null) { msg.Header[FieldCode.Destination] = UniqueName; } if (shouldDump) { MessageDumper.WriteComment("Sending:", Console.Out); MessageDumper.WriteMessage(msg, Console.Out); } //return base.Send (msg); return(SendReal(msg)); }
public override void HandleMessage(Message msg) { if (!isConnected) { return; } if (msg == null) { Console.Error.WriteLine("Disconnected!"); isConnected = false; //Server.Bus.RemoveConnection (this); //ServerBus sbus = Unregister (new ObjectPath ("/org/freedesktop/DBus")) as ServerBus; /* * ServerBus sbus = Unregister (new ObjectPath ("/org/freedesktop/DBus")) as ServerBus; * Register (new ObjectPath ("/org/freedesktop/DBus"), sbus); * sbus.RemoveConnection (this); */ Server.SBus.RemoveConnection(this); //Server.ConnectionLost (this); return; } Server.CurrentMessageConnection = this; Server.CurrentMessage = msg; try { if (shouldDump) { MessageDumper.WriteComment("Handling:", Console.Out); MessageDumper.WriteMessage(msg, Console.Out); } if (UniqueName != null) { msg.Header[FieldCode.Sender] = UniqueName; } object fieldValue = msg.Header[FieldCode.Destination]; if (fieldValue != null) { if ((string)fieldValue == ServerBus.DBusBusName) { // Workaround for our daemon only listening on a single path if (msg.Header.MessageType == NDesk.DBus.MessageType.MethodCall) { msg.Header[FieldCode.Path] = ServerBus.Path; } base.HandleMessage(msg); //return; } } //base.HandleMessage (msg); Server.SBus.HandleMessage(msg); } finally { Server.CurrentMessageConnection = null; Server.CurrentMessage = null; } }