public void init() { try { //incializamos una configuracion configuration = new Configuration(); //OS configuration.NetData.OpSystem = OpSystemType.WIN7; //configuramos los controles statusControl.connectNotification += connect; statusControl.disConnectNotification += disconnect; chatControl.NetUser = configuration.NetUser; //configuramos los sub protocolos SubProtocolList subProtocols = new SubProtocolList(); chatProtocol = new ChatProtocol(chatControl); subProtocols.add(SubProtocol.Chat.Types.CHATPROTOCOL, chatProtocol); fileTransferProtocol = new FileTransferProtocol(fileControl, fileListControl, createFileData()); subProtocols.add(SubProtocol.FileTransfer.Types.FILETRANSFERPROTOCOL, fileTransferProtocol); pingProtocol = new PingProtocol(this); subProtocols.add(SubProtocol.Ping.Types.PINGPROTOCOL, pingProtocol); chatControl.ChatProtocol = chatProtocol; fileListControl.FileTransferProtocol = fileTransferProtocol; //Configuramos los tipos de mensajes que no pertenecen a subprotocolos MessageTypeList messageTypeList = new MessageTypeList(); //se crea el objeto de comunicación communication = new Communication(configuration, subProtocols, messageTypeList); //Se setean los handlers de los eventos de usuarios communication.addUserEvent += netUserControl.addUserHandler; communication.addUserEvent += fileTransferProtocol.sendFileListRequest; communication.addUserEvent += networkGraphControl.addUserHandler; communication.refreshUserEvent += netUserControl.refreshUserHandler; communication.refreshUserEvent += networkGraphControl.refreshUserHandler; communication.refreshLocalUserEvent += netUserControl.refreshLocalUserHandler; communication.refreshLocalUserEvent += networkGraphControl.refreshLocalUserHandler; communication.removeUserEvent += netUserControl.removeUserHandler; communication.removeUserEvent += fileListControl.removeFileList; communication.removeUserEvent += networkGraphControl.removeUserHandler; //Se setean los handlers de los eventos de conexion communication.connectEvent += statusControl.connectHandler; communication.connectEvent += fileTransferProtocol.start; communication.connectingEvent += statusControl.connectingHandler; communication.disconnectEvent += statusControl.disconnectHandler; communication.disconnectEvent += fileTransferProtocol.stop; communication.disconnectEvent += clear; communication.disconnectingEvent += statusControl.disconnectingHandler; communication.reconnectingEvent += statusControl.reconnectingHandler; communication.reconnectingEvent += fileTransferProtocol.stop; communication.reconnectingEvent += clear; //Se setean los handlers de los eventos del sistems communication.exceptionEvent += exceptionHandler; communication.netInformationEvent += netInformationHandler; //iniciamos el consumidor de eventos communication.startEventConsumer(); //Se abre el archivo para log FileInfo t = new FileInfo("CommLayer.log"); Tex = t.AppendText(); } catch (Exception e) { MessageBox.Show("Ups!: " + e.Message); Close(); } }
public void init() { try { //se inicializa la configuración configuration = new Configuration(); configuration.NetData.OpSystem = NetLayer.OpSystemType.WINMOBILE5POCKETPC; //Configuración de controles statusControl.connectNotification += connect; statusControl.disConnectNotification += disconnect; chatControl.NetUser = configuration.NetUser; //Configuración de subprotocolos SubProtocolList subProtocols = new SubProtocolList(); chatProtocol = new ChatProtocol(chatControl); subProtocols.add(SubProtocol.Chat.Types.CHATPROTOCOL, chatProtocol); fileTransferProtocol = new FileTransferProtocol(fileControl, fileListControl, createFileData()); subProtocols.add(SubProtocol.FileTransfer.Types.FILETRANSFERPROTOCOL, fileTransferProtocol); pingProtocol = new PingProtocol(this); subProtocols.add(SubProtocol.Ping.Types.PINGPROTOCOL, pingProtocol); chatControl.ChatProtocol = chatProtocol; fileListControl.FileTransferProtocol = fileTransferProtocol; //se crea el objeto de comunicación communication = new Communication(configuration, subProtocols, null); //Se setean los handlers de los eventos de usuarios communication.addUserEvent += netUserControl.addUserHandler; communication.addUserEvent += fileTransferProtocol.sendFileListRequest; communication.refreshUserEvent += netUserControl.refreshUserHandler; communication.refreshLocalUserEvent += netUserControl.refreshLocalUserHandler; communication.removeUserEvent += netUserControl.removeUserHandler; communication.removeUserEvent += fileListControl.removeFileList; //Se setean los handlers de los eventos de conexion communication.connectEvent += statusControl.connectHandler; communication.connectEvent += fileTransferProtocol.start; communication.connectingEvent += statusControl.connectingHandler; communication.disconnectEvent += statusControl.disconnectHandler; communication.disconnectEvent += fileTransferProtocol.stop; communication.disconnectEvent += clear; communication.disconnectingEvent += statusControl.disconnectingHandler; communication.reconnectingEvent += statusControl.reconnectingHandler; communication.reconnectingEvent += fileTransferProtocol.stop; communication.reconnectingEvent += clear; //se setean los handlers de los eventos del sistema communication.exceptionEvent += exceptionHandler; communication.netInformationEvent += log; //iniciamos el consumidor de eventos communication.startEventConsumer(); } catch (Exception e) { MessageBox.Show("Ups!: " + e.Message); Close(); } }