Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Net.ClientContext"/> class.
        /// </summary>
        /// <param name="connectionId">Client.</param>
        public ClientContext(int connectionId)
        {
            DebugEx.VerboseFormat("ClientContext(connectionId = {0}) created", connectionId);

            if (sAllStates == null)
            {
                sAllStates = new IClientState[(int)ClientState.Count];
                sAllStates[(int)ClientState.Disconnected]        = new DisconnectedState();
                sAllStates[(int)ClientState.Connecting]          = null;
                sAllStates[(int)ClientState.Connected]           = new ConnectedState();
                sAllStates[(int)ClientState.RequestingMD5Hashes] = new RequestingMD5HashesState();
                sAllStates[(int)ClientState.Downloading]         = new DownloadingState();
            }

            mState        = ClientState.Connected;
            mCurrentState = sAllStates[(int)mState];

            mConnectionId = connectionId;
            mRevision     = -1;
            mFiles        = null;



            mCurrentState.OnEnter(this, ClientState.Count);
        }
Beispiel #2
0
        public override void Run(IDictionary <string, string> args = null)
        {
            base.Run(args);

            _log.Info("Starting Modules");

            ObtainConfiguredModules();

            IStatesRepository statesRepository = ServiceLocator.Current.GetInstance <IStatesRepository>();
            IClientState      clientState      = statesRepository.GetInstance <IClientState>();
            ICryptoService    cryptoService    = ServiceLocator.Current.GetInstance <ICryptoService>();

            if (args.ContainsKey("secretKey"))
            {
                byte[] secretKey = args["secretKey"].HexStringToByteArray();
                clientState.InitializeAccountBased(secretKey);
                cryptoService.Initialize(secretKey);
            }

            try
            {
                IModulesRepository modulesRepository = ServiceLocator.Current.GetInstance <IModulesRepository>();
                foreach (IModule module in modulesRepository.GetBulkInstances())
                {
                    module.Start();
                }
            }
            finally
            {
                _log.Info("Modules started");
            }
        }
        /// <summary>
        /// Gets status of the basket, expressed as a series of requisites, each composed of an action needed to be completed,
        /// an optional reference to the completion item, plus any (optional) requirements / actions that needs to complete
        /// in order to mark this action as completed.
        /// The action / requirement model depends on you to have an understanding how to fulfill each requirement.
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="state"></param>
        /// <param name="basketId"></param>
        /// <returns></returns>
        public static DataItemsResponseBody <BasketRequisiteResponse> GetBasketStatus(
            this Connection conn,
            IClientState state,
            int basketId
            )
        {
            var restRequest = conn.CreateRestRequestJson(
                Method.GET,
                "/services/v3/baskets/{basketId}/status"
                )
                              .AddParameter(
                "basketId",
                basketId,
                ParameterType.UrlSegment
                );


            var(_, response) = conn.Execute <DataItemsResponse <BasketRequisiteResponse> >(
                restRequest,
                state,
                Includes.Auth
                );

            return(response.Data);
        }
        /// <summary>
        /// Gets a list of your available baskets.
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="state"></param>
        /// <returns></returns>
        public static List <BasketResponse> GetBaskets(this Connection conn, IClientState state)
        {
            var restRequest = new RestRequest("/services/v3/baskets")
            {
                Method        = Method.GET,
                RequestFormat = DataFormat.Json
            };

            restRequest.AddParameter(
                "include",
                "description",
                ParameterType.QueryString
                ).AddParameter(
                "imagesizetypeids",
                "1",
                ParameterType.QueryString
                );

            var(_, response) = conn.Execute <DataItemsResponse <BasketResponse> >(
                restRequest,
                state,
                Includes.Auth
                );

            return(response.Data.Items);
        }
        /// <summary>
        /// Gets detailed information on a specific basket.
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="state"></param>
        /// <param name="basketId"></param>
        /// <returns></returns>
        public static BasketResponse GetBasket(
            this Connection conn,
            IClientState state,
            int basketId
            )
        {
            var restRequest = conn.CreateRestRequestJson(
                Method.GET,
                "/services/v3/baskets/{basketId}"
                )
                              .AddParameter(
                "basketId",
                basketId,
                ParameterType.UrlSegment
                )
                              .AddParameter(
                "include",
                "description",
                ParameterType.QueryString
                );


            var(_, response) = conn.Execute <DataResponse <BasketResponse> >(
                restRequest,
                state,
                true
                );

            return(response.Data);
        }
        /// <summary>
        /// Gets all lines for the specified basket.
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="state"></param>
        /// <param name="basketId"></param>
        /// <returns></returns>
        public static List <BasketLineResponse> GetBasketLines(
            this Connection conn,
            IClientState state,
            int basketId
            )
        {
            var restRequest = conn.CreateRestRequestJson(
                Method.GET,
                "/services/v3/baskets/{basketId}/lines"
                )
                              .AddParameter(
                "basketId",
                basketId,
                ParameterType.UrlSegment
                )
                              .AddParameter(
                "include",
                "description",
                ParameterType.QueryString
                ).AddParameter(
                "imagesizetypeids",
                "240",
                ParameterType.QueryString
                );


            var(_, response) = conn.Execute <DataItemsResponse <BasketLineResponse> >(
                restRequest,
                state,
                Includes.Auth
                );

            return(response.Data.Items);
        }
 public static void Set(this IClientState state, IClientState source)
 {
     foreach (var prop in source.GetType().GetProperties().Where(x => x.CanWrite))
     {
         prop.SetValue(state, prop.GetValue(source));
     }
 }
        /// <summary>
        /// Gets the state of the basket, i.e. properties, that may or should affect the client state.
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="state"></param>
        /// <param name="basketId"></param>
        /// <returns></returns>
        public static (List <HeaderSetMessage> HeaderSetMessages, Context BasketResponse) GetBasketState(
            this Connection conn,
            IClientState state,
            int basketId
            )
        {
            var restRequest = conn.CreateRestRequestJson(
                Method.GET,
                "/services/v3/baskets/{basketId}/state"
                )
                              .AddParameter(
                "basketId",
                basketId,
                ParameterType.UrlSegment
                )
                              .AddParameter(
                "include",
                "description",
                ParameterType.QueryString
                );


            var(headerSetMessages, response) = conn.Execute <DataResponse <Context> >(
                restRequest,
                state,
                Includes.Auth
                );

            return(headerSetMessages, response.Data);
        }
Beispiel #9
0
 public VoteViewModel(IDataAccessService dataAccessService, IStatesRepository statesRepository,
                      IBlockParsersRepositoriesRepository blockParsersRepositoriesRepository, IWalletManager walletManager)
 {
     _dataAccessService = dataAccessService;
     _blockParsersRepositoriesRepository = blockParsersRepositoriesRepository;
     _walletManager = walletManager;
     _clientState   = statesRepository.GetInstance <IClientState>();
 }
Beispiel #10
0
 public ResultsViewModel(IDataAccessService dataAccessService, IWalletManager walletManager,
                         IBlockParsersRepositoriesRepository blockParsersRepositoriesRepository, IStatesRepository statesRepository)
 {
     _dataAccessService = dataAccessService;
     _walletManager     = walletManager;
     _blockParsersRepositoriesRepository = blockParsersRepositoriesRepository;
     _clientState = statesRepository.GetInstance <IClientState>();
     Utxos        = new ObservableCollection <UtxoIncomingBlockDesc>();
 }
Beispiel #11
0
    /**
     * When a session is left succesfully, change to the starter state, refresh, and update notification bar
     */
    public void OnSessionLeaveSuccess()
    {
        currentState = clientStates[STARTED_STATE];
        currentState.refresh();

        this.Title = "Screenary";

        DisplayStatusText("You have succesfully left the session.");
    }
Beispiel #12
0
    /**
     * When a users has succesfully authenticated into a session, change to the authenticated state, refresh, and update notification bar
     */
    public void OnSessionAuthenticationSuccess()
    {
        currentState = clientStates[RECEIVER_AUTHENTICATED_STATE];
        currentState.refresh();

        this.Title = "Screenary - Session: " + sessionKey;

        DisplayStatusText("You have successfully joined the session! SessionKey: " + sessionKey);
    }
Beispiel #13
0
 public PollViewModel(IWalletManager walletManager, IStatesRepository statesRepository, IDataAccessService dataAccessService, IBlockParsersRepositoriesRepository blockParsersRepositoriesRepository)
 {
     InitPoll();
     Polls              = new ObservableCollection <IPoll>();
     _walletManager     = walletManager;
     _dataAccessService = dataAccessService;
     _blockParsersRepositoriesRepository = blockParsersRepositoriesRepository;
     _clientState     = statesRepository.GetInstance <IClientState>();
     ResultsViewModel = new ResultsViewModel(dataAccessService, walletManager, blockParsersRepositoriesRepository, statesRepository);
 }
Beispiel #14
0
        public RegistrationViewModel(IDataAccessService dataAccessService, IWalletManager walletManager, IStatesRepository statesRepository)
        {
            User            = new User();
            _clientState    = statesRepository.GetInstance <IClientState>();
            RegisteredUsers = new ObservableCollection <User>();

            _dataAccessService = dataAccessService;
            _walletManager     = walletManager;
            InitData();
        }
Beispiel #15
0
    static public void ChangeState(IClientState state)
    {
        if (CurrentState != null)
        {
            CurrentState.OnExit();
        }

        CurrentState = state;
        CurrentState.OnEntry();
    }
Beispiel #16
0
        public Client(ITcpClientAdapter tcpClient, CancellationToken cancellationToken, IMessager messager, IMimeParser mimeParser)
        {
            TcpClient         = tcpClient;
            CancellationToken = cancellationToken;

            _clientState = new ConnectedState(this, messager, mimeParser);

            // Change to the 'awaiting EHLO' state
            _clientState = new AwaitingEhloCommandState(this, messager, mimeParser);
        }
Beispiel #17
0
        public Client(ITcpClientAdapter tcpClient, CancellationToken cancellationToken, IMessager messager, IMimeParser mimeParser)
        {
            TcpClient = tcpClient;
            CancellationToken = cancellationToken;

            _clientState = new ConnectedState(this, messager, mimeParser);

            // Change to the 'awaiting EHLO' state
            _clientState = new AwaitingEhloCommandState(this, messager, mimeParser);
        }
Beispiel #18
0
    /**
     * When a session is terminated succesfully, change to the starter state, refresh, and update notification bar
     */
    public void OnSessionTerminationSuccess(char[] sessionKey)
    {
        currentState = clientStates[STARTED_STATE];
        currentState.refresh();

        this.Title = "Screenary";

        ExceptionDialog exception = new ExceptionDialog("Alert", "The session has been terminated.");

        DisplayStatusText("The session has been terminated.");
    }
Beispiel #19
0
    public MainWindow(int m) : base(Gtk.WindowType.Toplevel)
    {
        Build();

        /* Instantiate client states */
        clientStates = new IClientState[7]
        {
            new StartedState(this),
            new SenderCreatedState(this),
            new ReceiverJoinedState(this),
            new ReceiverAuthenticatedState(this),
            new SenderSendingState(this),
            new ReceiverInControlState(this),
            new SenderSendingRemoteState(this)
        };

        /* Set current state to STARTED */
        currentState = clientStates[STARTED_STATE];
        currentState.refresh();

        width  = 1024;
        height = 768;

        config = Config.Load();

        window   = mainDrawingArea.GdkWindow;
        drawable = (Gdk.Drawable)window;

        mainDrawingArea.AddEvents(
            (int)Gdk.EventMask.ButtonPressMask |
            (int)Gdk.EventMask.ButtonReleaseMask |
            (int)Gdk.EventMask.PointerMotionMask |
            (int)Gdk.EventMask.KeyPressMask |
            (int)Gdk.EventMask.KeyReleaseMask);

        gc = new Gdk.GC(drawable);
        gc.ClipRectangle = new Gdk.Rectangle(0, 0, width, height);

        surface = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, true, 8, width, height);
        window.InvalidateRect(new Gdk.Rectangle(0, 0, width, height), true);

        receiver = new SurfaceReceiver(window, surface);

        this.transport = null;

        pcapSource = new PcapSource(this);

        keyboard = new Keyboard();

        if (config.BroadcasterAutoconnect)
        {
            OnUserConnect(config.BroadcasterHostname, config.BroadcasterPort);
        }
    }
Beispiel #20
0
    /**
     * When a session is joined succesfully, change to the receiver state, refresh, and update notification bar
     */
    public void OnSessionJoinSuccess(char[] sessionKey, Boolean isPasswordProtected)
    {
        sessionClient.SendAuthReq(username, password);

        this.sessionKey = new string(sessionKey);

        currentState = clientStates[RECEIVER_JOINED_STATE];
        currentState.refresh();

        /* Update the input channel with the sessionId */
        inputClient.SetSessionId(sessionClient.GetSessionId());
    }
Beispiel #21
0
    /**
     * Notifies when a user has joined/left a session, who has control of the session. FOR NOW: Switching states when a user has
     * taken control.
     */
    public void OnSessionNotificationUpdate(string type, string username)
    {
        if (this.username.Equals(username) && type.Equals("joined"))
        {
            DisplayStatusText("You have successfully joined the session.");
        }
        else if (this.username.Equals(username) && type.Equals("control of"))
        {
            DisplayStatusText("You have control of the session.");
        }
        else
        {
            DisplayStatusText(username + " has " + type + " the session.");
        }

        if (type.Equals("control of") && this.username.Equals(username))
        {
            // Save the controller's username
            controller = username;
            if (currentState == clientStates[RECEIVER_AUTHENTICATED_STATE])
            {
                currentState = clientStates[RECEIVER_IN_CONTROL_STATE];
                currentState.refresh();
                DisplayParticipants();
            }

            if (currentState == clientStates[SENDER_SENDING_REMOTE_STATE])
            {
                currentState = clientStates[SENDER_SENDING_STATE];
                currentState.refresh();
                DisplayParticipants();
            }
        }

        if (type.Equals("control of") && !this.username.Equals(username))
        {
            // Save controller's username
            controller = username;
            if (currentState == clientStates[RECEIVER_IN_CONTROL_STATE])
            {
                currentState = clientStates[RECEIVER_AUTHENTICATED_STATE];
                currentState.refresh();
                DisplayParticipants();
            }

            if (currentState == clientStates[SENDER_CREATED_STATE] || currentState == clientStates[SENDER_SENDING_STATE])
            {
                currentState = clientStates[SENDER_SENDING_REMOTE_STATE];
                currentState.refresh();
                DisplayParticipants();
            }
        }
    }
Beispiel #22
0
        public static MenuItemsResponseBody <MenuItem> GetSpecificProductMenusWithDepth(
            this Connection conn,
            IClientState state,
            int menuId,
            [CanBeNull] IEnumerable <int> imagesizetypeids,
            int depth
            )
        {
            var restRequest = conn.CreateRestRequestJson(
                Method.GET,
                "/services/v3/menus/productmenu/"
                );

            restRequest.AddParameter(
                "mId",
                menuId,
                ParameterType.UrlSegment
                );

            restRequest.AddParameter(
                "depth",
                depth,
                ParameterType.QueryString
                );

            if (imagesizetypeids != null)
            {
                restRequest.AddParameter(
                    "imagesizetypeids",
                    string.Join(
                        ",",
                        imagesizetypeids
                        ),
                    ParameterType.QueryString
                    );
            }
            else
            {
                restRequest.AddParameter(
                    "imagesizetypeids",
                    1,
                    ParameterType.QueryString
                    );
            }

            var(_, response) = conn.Execute <MenuItemResponse <MenuItem> >(
                restRequest,
                state,
                Includes.Ticket
                );

            return(response.Data);
        }
Beispiel #23
0
    /**
     * When a session is created succesfully, change to the sender state, refresh, and update notification bar
     */
    public void OnSessionCreationSuccess(char[] sessionKey)
    {
        string sessionKeyString = new string(sessionKey);

        this.sessionKey = sessionKeyString;

        currentState = clientStates[SENDER_CREATED_STATE];

        currentState.refresh();

        this.Title = "Screenary - Session: " + sessionKeyString;

        CreationDialog dialog = new CreationDialog(sessionKeyString);
    }
        public static DataResponse <CustomerForSalesPersonResponse> CustomersForCurrentSalesPerson(
            this Connection conn,
            IClientState state,
            string searchFor,
            int?page,
            int?pageSize
            )
        {
            var restRequest = conn.CreateRestRequestJson(
                Method.GET,
                "/services/v3/salespersons/current/customers"
                );

            if (searchFor.ToNullIfWhite() != null)
            {
                restRequest.AddParameter(
                    "search",
                    searchFor,
                    ParameterType.QueryString
                    );
            }

            if (page != null)
            {
                restRequest.AddParameter(
                    "p",
                    page,
                    ParameterType.QueryString
                    );
            }

            if (pageSize != null)
            {
                restRequest.AddParameter(
                    "rp",
                    pageSize,
                    ParameterType.QueryString
                    );
            }


            var(_, response) = conn.Execute <DataResponse <CustomerForSalesPersonResponse> >(
                restRequest,
                state,
                Includes.Auth
                );

            return(response);
        }
 public static (List <HeaderSetMessage> HeaderSetMessages, Context Data) GetContext(
     this Connection conn,
     IClientState state
     )
 {
     var(headerSetMessages, response) = conn.Execute <DataResponse <Context> >(
         new RestRequest("/services/v3/context")
     {
         Method = Method.GET
     },
         state,
         Includes.None
         );
     return(headerSetMessages, response.Data);
 }
Beispiel #26
0
 public WalletManager(INetworkAdapter networkAdapter, IBlockCreator blockCreator, IDataAccessService dataAccessService, IHashCalculationsRepository hashCalculationsRepository,
                      IIdentityKeyProvidersRegistry identityKeyProvidersRegistry, IStatesRepository statesRepository, ISerializersFactory signatureSupportSerializersFactory,
                      IBlockParsersRepositoriesRepository blockParsersRepositoriesRepository)
 {
     _networkAdapter    = networkAdapter;
     _blockCreator      = blockCreator;
     _dataAccessService = dataAccessService;
     _signatureSupportSerializersFactory = signatureSupportSerializersFactory;
     _blockParsersRepositoriesRepository = blockParsersRepositoriesRepository;
     _heightsDictionary      = new Dictionary <byte[], ulong>();
     _hashCalculation        = hashCalculationsRepository.Create(Globals.DEFAULT_HASH);
     _proofOfWorkCalculation = hashCalculationsRepository.Create(Globals.POW_TYPE);
     _identityKeyProvider    = identityKeyProvidersRegistry.GetInstance();
     _clientState            = statesRepository.GetInstance <IClientState>();
 }
 public static LogRequest WriteLog(
     this Connection conn,
     IClientState state,
     LogRequest logRequest
     )
 {
     var(headerSetMessages, response) = conn.Execute <LogRequest>(
         logRequest.CreateRestRequestJson(
             Method.POST,
             "/services/v3/logs"
             ),
         state,
         Includes.Hmac
         );
     return(response);
 }
        public static bool DeleteBasket(this Connection conn, IClientState state, int basketId)
        {
#pragma warning disable CA1305 // Specify IFormatProvider
            var restRequest = new RestRequest(string.Format("{0}/{1}", "/services/v3/baskets", basketId))
#pragma warning restore CA1305 // Specify IFormatProvider
            {
                Method = Method.DELETE
            };


            var(_, success) = conn.ExecuteNonQuery <bool>(
                restRequest,
                state,
                Includes.Auth
                );
            return(success);
        }
        public static DataItemsResponseBody <Currency> GetCurrencies(
            this Connection conn,
            IClientState state)
        {
            var restRequest = conn.CreateRestRequestJson(
                Method.GET,
                "/services/v3/currencies"
                );

            var(_, response) = conn.Execute <DataItemsResponse <Currency> >(
                restRequest,
                state,
                Includes.Ticket
                );

            return(response.Data);
        }
        public ClientEditViewModel(IRepository repository, IDialogService dialogService)
        {
            this._repository    = repository;
            this._dialogService = dialogService;

            this.InitPropertyInfos();
            this.InitStates();
            this.InitStateCommands();

            this._currentState = this.GetClientEmptyState();
            this.SetCurrentClient(new Client {
                CityToPostalCode = new CityToPostalCode()
            });

            Messenger.Default.Register <NotificationMessage <int> >(this, this.ExecuteNotificationMessage);
            Messenger.Default.Register <NotificationMessage>(this, this.ExecuteNotificationMessage);
        }
        public static bool RemoveCoupons(this Connection conn,
                                         IClientState state,
                                         int basketId)
        {
            var restRequest = new RestRequest("/services/v3/baskets/{basketId}/coupons", Method.DELETE)
                              .AddParameter(
                "basketId",
                basketId,
                ParameterType.UrlSegment
                );

            var(_, success) = conn.ExecuteNonQuery <bool>(
                restRequest,
                state,
                Includes.Auth
                );
            return(success);
        }
Beispiel #32
0
    public MainWindow(int m)
        : base(Gtk.WindowType.Toplevel)
    {
        Build();

        /* Instantiate client states */
        clientStates = new IClientState[4] {
            new StartedState(this),
            new SenderCreatedState(this),
            new ReceiverJoinedState(this),
            new ReceiverAuthenticatedState(this)
        };

        /* Set current state to STARTED */
        currentState = clientStates[STARTED_STATE];

        mode = m;
        width = 1024;
        height = 768;

        config = Config.Load();

        window = mainDrawingArea.GdkWindow;
        drawable = (Gdk.Drawable) window;

        gc = new Gdk.GC(drawable);
        gc.ClipRectangle = new Gdk.Rectangle(0, 0, width, height);

        surface = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, true, 8, width, height);
        window.InvalidateRect(new Gdk.Rectangle(0, 0, width, height), true);

        receiver = new SurfaceReceiver(window, surface);

        OutOfSessionWindow();

        this.transport = null;

        rdpSource = new RdpSource(this);
        pcapSource = new PcapSource(this);

        if (config.BroadcasterAutoconnect)
            OnUserConnect(config.BroadcasterHostname, config.BroadcasterPort);
    }
Beispiel #33
0
    /**
     * When a session is left succesfully, change to the starter state, refresh, and update notification bar
     */
    public void OnSessionLeaveSuccess()
    {
        currentState = clientStates[STARTED_STATE];
        currentState.refresh();

        this.Title = "Screenary";

        DisplayStatusText("You have succesfully left the session.");
    }
Beispiel #34
0
 public void ChangeState(IClientState state)
 {
     _clientState = state;
 }
Beispiel #35
0
    /**
     * When a users has succesfully authenticated into a session, change to the authenticated state, refresh, and update notification bar
     */
    public void OnSessionAuthenticationSuccess()
    {
        currentState = clientStates[RECEIVER_AUTHENTICATED_STATE];
        currentState.refresh();

        this.Title = "Screenary - Session: " + sessionKey;

        DisplayStatusText("You have successfully joined the session! SessionKey: " + sessionKey);
    }
Beispiel #36
0
    /**
     * When a session is created succesfully, change to the sender state, refresh, and update notification bar
     */
    public void OnSessionCreationSuccess(char[] sessionKey)
    {
        string sessionKeyString = new string(sessionKey);

        this.sessionKey = sessionKeyString;

        currentState = clientStates[SENDER_CREATED_STATE];

        currentState.refresh();

        this.Title = "Screenary - Session: " + sessionKeyString;

        CreationDialog dialog = new CreationDialog(sessionKeyString);
    }
Beispiel #37
0
    /**
     * When a session is joined succesfully, change to the receiver state, refresh, and update notification bar
     */
    public void OnSessionJoinSuccess(char[] sessionKey, Boolean isPasswordProtected)
    {
        sessionClient.SendAuthReq(username,password);

        this.sessionKey = new string(sessionKey);

        currentState = clientStates[RECEIVER_JOINED_STATE];
        currentState.refresh();

        /* Update the input channel with the sessionId */
        inputClient.SetSessionId(sessionClient.GetSessionId());
    }
Beispiel #38
0
    /**
     * Notifies when a user has joined/left a session, who has control of the session. FOR NOW: Switching states when a user has
     * taken control.
     */
    public void OnSessionNotificationUpdate(string type, string username)
    {
        if (this.username.Equals(username) && type.Equals("joined"))
        {
            DisplayStatusText("You have successfully joined the session.");
        }
        else if (this.username.Equals(username) && type.Equals("control of"))
        {
            DisplayStatusText("You have control of the session.");
        }
        else
        {
            DisplayStatusText(username + " has " + type + " the session.");
        }

        if (type.Equals("control of") && this.username.Equals(username))
        {
            // Save the controller's username
            controller = username;
            if (currentState == clientStates[RECEIVER_AUTHENTICATED_STATE])
            {
                currentState = clientStates[RECEIVER_IN_CONTROL_STATE];
                currentState.refresh();
                DisplayParticipants();
            }

            if (currentState == clientStates[SENDER_SENDING_REMOTE_STATE])
            {
                currentState = clientStates[SENDER_SENDING_STATE];
                currentState.refresh();
                DisplayParticipants();
            }

        }

        if (type.Equals("control of") && !this.username.Equals(username))
        {
            // Save controller's username
            controller = username;
            if (currentState == clientStates[RECEIVER_IN_CONTROL_STATE])
            {
                currentState = clientStates[RECEIVER_AUTHENTICATED_STATE];
                currentState.refresh();
                DisplayParticipants();
            }

            if (currentState == clientStates[SENDER_CREATED_STATE] || currentState == clientStates[SENDER_SENDING_STATE])
            {
                currentState = clientStates[SENDER_SENDING_REMOTE_STATE];
                currentState.refresh();
                DisplayParticipants();
            }
        }
    }
Beispiel #39
0
    /**
     * When a session is terminated succesfully, change to the starter state, refresh, and update notification bar
     */
    public void OnSessionTerminationSuccess(char[] sessionKey)
    {
        currentState = clientStates[STARTED_STATE];
        currentState.refresh();

        this.Title = "Screenary";

        ExceptionDialog exception = new ExceptionDialog("Alert", "The session has been terminated.");

        DisplayStatusText("The session has been terminated.");
    }
Beispiel #40
0
    public MainWindow(int m)
        : base(Gtk.WindowType.Toplevel)
    {
        Build();

        /* Instantiate client states */
        clientStates = new IClientState[7]
        {
            new StartedState(this),
            new SenderCreatedState(this),
            new ReceiverJoinedState(this),
            new ReceiverAuthenticatedState(this),
            new SenderSendingState(this),
            new ReceiverInControlState(this),
            new SenderSendingRemoteState(this)
        };

        /* Set current state to STARTED */
        currentState = clientStates[STARTED_STATE];
        currentState.refresh();

        width = 1024;
        height = 768;

        config = Config.Load();

        window = mainDrawingArea.GdkWindow;
        drawable = (Gdk.Drawable) window;

        mainDrawingArea.AddEvents(
            (int) Gdk.EventMask.ButtonPressMask |
            (int) Gdk.EventMask.ButtonReleaseMask |
            (int) Gdk.EventMask.PointerMotionMask |
            (int) Gdk.EventMask.KeyPressMask |
            (int) Gdk.EventMask.KeyReleaseMask);

        gc = new Gdk.GC(drawable);
        gc.ClipRectangle = new Gdk.Rectangle(0, 0, width, height);

        surface = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, true, 8, width, height);
        window.InvalidateRect(new Gdk.Rectangle(0, 0, width, height), true);

        receiver = new SurfaceReceiver(window, surface);

        this.transport = null;

        pcapSource = new PcapSource(this);

        keyboard = new Keyboard();

        if (config.BroadcasterAutoconnect)
            OnUserConnect(config.BroadcasterHostname, config.BroadcasterPort);
    }