/* * private void OnNewChannel (ObjectPath object_path, string channel_type, HandleType handle_type, * uint handle, bool suppress_handler) * { * Console.WriteLine (MSG_PREFIX + "OnNewChannel: op {0}, type {1}, handle {2}", * object_path, channel_type, handle); * * if (channel_type.Equals (CHANNEL_TYPE_DBUSTUBE)) { * itube = bus.GetObject<IDBusTube> (CONNMANAGER_GABBLE_IFACE, object_path); * //itube.NewTube += OnNewTube; * itube.TubeChannelStateChanged += OnTubeChannelStateChanged; * * // get tube initiator handle * // should be = to self_handle on client * // should be != to self_handle on server * Properties p = bus.GetObject<Properties> (CONNMANAGER_GABBLE_IFACE, object_path); * tube_initiator = (uint) p.Get (CHANNEL_IFACE, "InitiatorHandle"); * * if (tube_initiator == self_handle) { * Console.WriteLine (MSG_PREFIX + "Offering DTube"); * addr = itube.OfferDBusTube (new Dictionary<string, object>()); * Console.WriteLine (MSG_PREFIX + "Tube from {0} offered", addr); * } * else { * addr = itube.AcceptDBusTube (); * Console.WriteLine (MSG_PREFIX + "Tube from {0} accepted", addr); * } * * } * } */ /* * private void OnNewTube (uint id, uint initiator, TubeType type, string service, * IDictionary<string,object> parameters, TubeState state) * { * Console.WriteLine (MSG_PREFIX + "OnNewTube: id {0), initiator {1}, service {2}", * id, initiator, service); * switch (state) { * case TubeState.LocalPending: * if (type == TubeType.DBus && initiator != self_handle && service.Equals (DTUBETEST_IFACE)) { * Console.WriteLine (MSG_PREFIX + "Accepting DTube"); * itube.AcceptDBusTube (id); * } * break; * } * * } */ private void OnTubeChannelStateChanged(TubeChannelState state) { Console.WriteLine(MSG_PREFIX + "OnTubeStateChanged: state {0}", state); switch (state) { // this state is never reached, so accepting OnNewChannel // leaving here just in case, however case TubeChannelState.LocalPending: addr = itube.Accept(SocketAccessControl.Localhost); Console.WriteLine(MSG_PREFIX + "Tube from {0} accepted", addr); break; // tube ready. set up connection and export/get object case TubeChannelState.Open: dbus_conn = Connection.Open(addr); BusG.Init(dbus_conn); if (tube_initiator != self_handle) { RegisterDBusObject(); } else { obj = dbus_conn.GetObject <IDTubeTest> (DTUBETEST_IFACE, new ObjectPath(DTUBETEST_PATH)); obj.TestSignal += OnTestSignal; obj.Hello(); IDictionary <string, object>[] dic = obj.HelloDictionary(); Console.WriteLine(MSG_PREFIX + "Got response on tube. Dictionary array has {0} items.", dic.Length); TestStruct[] ts = obj.HelloStruct(); Console.WriteLine(MSG_PREFIX + "Got response on tube. Struct array has {0} items", ts.Length); Properties p = dbus_conn.GetObject <Properties> (DTUBETEST_IFACE, new ObjectPath(DTUBETEST_PATH)); string property = (string)p.Get(DTUBETEST_IFACE, "TestProperty"); Console.WriteLine(MSG_PREFIX + "Got response on tube. Property {0}", property); itube.Close(); } break; case TubeChannelState.NotOffered: break; } }
private void OnNewChannels(ChannelDetails[] channels) { foreach (ChannelDetails c in channels) { ObjectPath object_path = c.Channel; string channel_type = c.Properties["org.freedesktop.Telepathy.Channel.ChannelType"] as string; HandleType handle_type = (HandleType)c.Properties["org.freedesktop.Telepathy.Channel.TargetHandleType"]; uint handle = (uint)c.Properties["org.freedesktop.Telepathy.Channel.TargetHandle"]; Console.WriteLine(MSG_PREFIX + "OnNewChannels: op {0}, channel_type {1}, handle_type {2}, handle {3}", object_path, channel_type, handle_type, handle); if (channel_type.Equals(Constants.CHANNEL_TYPE_DBUSTUBE)) { itube = bus.GetObject <IDBusTube> (Constants.CONNMANAGER_GABBLE_IFACE, object_path); //itube.NewTube += OnNewTube; itube.TubeChannelStateChanged += OnTubeChannelStateChanged; itube.Closed += OnTubeClosed; // get tube initiator handle // should be = to self_handle on client // should be != to self_handle on server Properties p = bus.GetObject <Properties> (Constants.CONNMANAGER_GABBLE_IFACE, object_path); tube_initiator = (uint)p.Get(Constants.CHANNEL_IFACE, "InitiatorHandle"); if (tube_initiator == self_handle) { Console.WriteLine(MSG_PREFIX + "Offering DTube"); addr = itube.Offer(new Dictionary <string, object>(), SocketAccessControl.Localhost); Console.WriteLine(MSG_PREFIX + "Tube from {0} offered", addr); } else { addr = itube.Accept(SocketAccessControl.Localhost); Console.WriteLine(MSG_PREFIX + "Tube from {0} accepted", addr); } } } }
public void Accept() { address = tube.Accept(SocketAccessControl.Localhost); Console.WriteLine("Tube from {0} accepted", address); }
private void OnNewChannels(ChannelDetails[] channels) { foreach (ChannelDetails c in channels) { ObjectPath object_path = c.Channel; string channel_type = c.Properties["org.freedesktop.Telepathy.Channel.ChannelType"] as string; HandleType handle_type = (HandleType) c.Properties["org.freedesktop.Telepathy.Channel.TargetHandleType"]; uint handle = (uint) c.Properties["org.freedesktop.Telepathy.Channel.TargetHandle"]; Console.WriteLine (MSG_PREFIX + "OnNewChannels: op {0}, channel_type {1}, handle_type {2}, handle {3}", object_path, channel_type, handle_type, handle); if (channel_type.Equals (Constants.CHANNEL_TYPE_DBUSTUBE)) { itube = bus.GetObject<IDBusTube> (Constants.CONNMANAGER_GABBLE_IFACE, object_path); //itube.NewTube += OnNewTube; itube.TubeChannelStateChanged += OnTubeChannelStateChanged; itube.Closed += OnTubeClosed; // get tube initiator handle // should be = to self_handle on client // should be != to self_handle on server Properties p = bus.GetObject<Properties> (Constants.CONNMANAGER_GABBLE_IFACE, object_path); tube_initiator = (uint) p.Get (Constants.CHANNEL_IFACE, "InitiatorHandle"); if (tube_initiator == self_handle) { Console.WriteLine (MSG_PREFIX + "Offering DTube"); addr = itube.Offer (new Dictionary<string, object>(), SocketAccessControl.Localhost); Console.WriteLine (MSG_PREFIX + "Tube from {0} offered", addr); } else { addr = itube.Accept (SocketAccessControl.Localhost); Console.WriteLine (MSG_PREFIX + "Tube from {0} accepted", addr); } } } }