protected void messageReceived(ConnectionEventArgs a) { PUC.Communication.Message msg = a.GetMessage(); if (msg is DeviceSpec) { DeviceSpec dmsg = (DeviceSpec)msg; Appliance appl = new Appliance(this); #if POCKETPC Globals.AddFrameMapping(appl, PUCFrame.DEFAULT_FRAME); #endif #if SMARTPHONE Globals.AddFrameMapping(appl, PhonePUC.PUCFrame.DEFAULT_FRAME); #endif #if DESKTOP && !DEBUGSVR // TODO: Make DesktopPUC use multiple windows, like Debug Server Globals.AddFrameMapping(appl, DesktopPUC.PUCFrame.DEFAULT_FRAME); #endif try { SpecParser.Parse(new StringReader(dmsg.GetSpec()), appl); MenuItem mi = new MenuItem(); mi.Text = appl.Name; appl.SetMenuItem(mi); _server.ActivateAppliance(this, appl); Cursor.Current = Cursors.Default; _connection.MessageReceivedEvent -= new Connection.MessageReceivedHandler(this.messageReceived); _connection.ConnectionRegainedEvent -= new Connection.ConnectionRegainedHandler(this.connectionRegained); _connection.ConnectionLostEvent += new Connection.ConnectionLostHandler(appl.ConnectionLost); _connection.MessageReceivedEvent += new Connection.MessageReceivedHandler(appl.MessageReceived); _connection.ConnectionRegainedEvent += new Connection.ConnectionRegainedHandler(appl.ConnectionRegained); FullStateRequest fsrMsg = new FullStateRequest(); _connection.Send(fsrMsg); } catch (Exception e) { Globals.GetFrame(appl).AddLogLine(e.ToString()); Cursor.Current = Cursors.Default; } } }
public void ConnectionRegained(ConnectionEventArgs a) { _uiGenerator.Enabled = true; Globals.GetFrame(this).AddLogLine("Reconnected to " + Name + "."); try { PUC.Communication.Message msg = new FullStateRequest(); _connection.Send(msg); } catch (Exception) { } MessageBox.Show("Regained connection to " + Name + ".", "Connection Regained"); }