Esempio n. 1
0
 public MainView(IAppContext appContext)
 {
     InitializeComponent();
     _appContext = appContext;
     _conn = (IClientToServerModel)_appContext.GetObject<IConnectionModel>();
     _conn.IP = "127.0.0.1";
     _conn.Port = 51414;
     _conn.Username = "******";
 }
Esempio n. 2
0
 public ConnectionWindow(IClientToServerModel config)
 {
     InitializeComponent();
      ipBinding = new Binding("Text", config, "IP");
      portBinding  = new Binding("Text", config, "Port");
      userBinding = new Binding("Text", config, "Username");
      tbIP.DataBindings.Add(ipBinding);
      tbPort.DataBindings.Add(portBinding);
      tbNick.DataBindings.Add(userBinding);
 }
Esempio n. 3
0
        public void Connect(IClientToServerModel _conn)
        {
            TcpClient tcpClient = new TcpClient();
                ISocketListener serverListener = _appcontext.
                                                GetObject<ISocketListener>();

                ITypeTranslator translator = _appcontext.
                                             GetObject<ITypeTranslator>();

                IEnumerable<IModuleHandler> modules = _appcontext.
                                            GetAllObjects<IModuleHandler>();

                tcpClient.Connect(_conn.IP, _conn.Port);
                _conn.Socket = tcpClient.Client;
                BackgroundWorker bgw = new BackgroundWorker();
                bgw.DoWork += new DoWorkEventHandler(serverListener.Start);
                bgw.RunWorkerAsync(_conn.Socket);

                IModuleHandler connHandler = _appcontext.GetAllObjects<IModuleHandler>().Where(x => x.HandleType == PaketType.ConnectionInfo).FirstOrDefault();
                if (connHandler != null)
                    connHandler.Do(null);
        }