Пример #1
0
    public override Response Execute()
    {
        var crypter       = MasterContainer.GetService <RsaCrpyter>();
        var clientCripter = crypter.StripPrivateKey();

        return(new HelloResponse(clientCripter.GetPublicXmlConfig()));
    }
Пример #2
0
 public BroadcastForm()
 {
     InitializeComponent();
     client      = MasterContainer.GetService <RequestSender>();
     currentUser = MasterContainer.GetService <User>();
     recForm     = new RecordForm();
 }
Пример #3
0
    public override Response Execute()
    {
        var db         = MasterContainer.GetService <IBroadcastDatabase>();
        var broadcasts = db.GetInterval(IntervalStart, IntervalEnd);

        return(new SelectBroadcastResponse(broadcasts));
    }
Пример #4
0
    public override Response Execute()
    {
        var db      = MasterContainer.GetService <IBroadcastDatabase>();
        var altered = db.Edit(BroadcastId, NewStartTime, NewLabel);

        return(new AlterBroadcastResponse(altered ? AlterBroadcastResult.Success : AlterBroadcastResult.NotFound));
    }
Пример #5
0
    public override Response Execute()
    {
        var db         = MasterContainer.GetService <IBroadcastDatabase>();
        var collisions = db.GetInterval(Broadcast.StartTime, Broadcast.EndTime);

        PlanBroadcastResult result;

        if (collisions.Length > 0)
        {
            var authorizator = MasterContainer.GetService <IAuthorizator>();
            // If there is a collission, admin can override it
            if (authorizator.HasPermission(User, Permission.AdminBroadcasts))
            {
                result = PlanBroadcastResult.CanUploadIfAdmin;
            }
            else
            {
                result = PlanBroadcastResult.CannotUpload;
            }
        }
        else
        {
            result = PlanBroadcastResult.CanUpload;
        }

        return(new PlanBroadcastResponse(result, collisions));
    }
Пример #6
0
        public LoginForm()
        {
            InitializeComponent();

            netSender = MasterContainer.GetService <RequestSender>();
            crypter   = MasterContainer.GetService <EncryptionProvider>();
        }
Пример #7
0
    public override Response Execute()
    {
        var    authenticator = MasterContainer.GetService <IAuthenticator>();
        string password      = Session.Crpter.DecryptString(User.PasswordEnc);
        var    result        = authenticator.Authenticate(User, password);

        return(new AuthenticateResponse(result));
    }
Пример #8
0
    public void SendGoodbye()
    {
        var user        = MasterContainer.GetService <User>();
        var goodbye     = new GoodbyeRequest(user);
        var requestData = EncryptRequest(goodbye, SessionCrypter);

        client.Send(requestData);
    }
Пример #9
0
    public override Response Execute()
    {
        var server  = MasterContainer.GetService <TcpServer>();
        var manager = MasterContainer.GetService <SessionManager>();

        server.DisconnectClient(Session.Host);
        manager.RemoveSession(Session);

        return(new SuccessResponse());
    }
Пример #10
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            this.sender = MasterContainer.GetService <RequestSender>();


            //var start = timeLine1.StartTime.AddMinutes(2);
            //var end = timeLine1.StartTime.AddMinutes(8);

            //var tasks = new TimeLineTask[] {
            //    new TimeLineTask(start, end, "V. Klínská"),
            //    new TimeLineTask(start.AddMinutes(3), end.AddMinutes(1), "M. Kaufmann") };

            //timeLine1.SetTasks(tasks);
        }
Пример #11
0
    public override Response Execute()
    {
        var authorizator = MasterContainer.GetService <IAuthorizator>();
        var granted      = new List <Permission>();

        foreach (Permission requested in RequestedPermissons)
        {
            if (authorizator.HasPermission(User, requested))
            {
                granted.Add(requested);
            }
        }

        return(new ListPermissionsResponse(granted.ToArray()));
    }
Пример #12
0
    public override Response Execute()
    {
        try
        {
            var reciever = MasterContainer.GetService <LiveBroadcastReciever>();
            reciever.Abort();
            MasterContainer.RemoveService <LiveBroadcastReciever>();

            return(new StopLiveBroadcastResponse(StopLiveBroadcastResults.Stopped));
        }
        catch
        {
            return(new StopLiveBroadcastResponse(StopLiveBroadcastResults.NoBroadcast));
        }
    }
Пример #13
0
        private void OnStop()
        {
            if (rcRecorder.Recording)
            {
                rcRecorder.Stop();
                streamer.StopStreaming();

                var client      = MasterContainer.GetService <RequestSender>();
                var currentUser = MasterContainer.GetService <User>();
                var request     = new StopLiveBroadcastRequest(currentUser);
                client.SendAndRecieve <StopLiveBroadcastResponse>(request);
            }
            rcRecorder.FrontColor = Color.Lime;
            btnRecord.Enabled     = true;
        }
Пример #14
0
    public override Response Execute()
    {
        var db      = MasterContainer.GetService <IBroadcastDatabase>();
        var removed = db.Remove(Broadcast.Id);

        if (removed)
        {
            var store = MasterContainer.GetService <FileStore>();
            if (Broadcast.Filename != null)
            {
                store.Delete(Broadcast.Filename);
            }
        }

        return(new AlterBroadcastResponse(removed? AlterBroadcastResult.Success : AlterBroadcastResult.NotFound));
    }
Пример #15
0
    //public IAudioCodec Codec { get; private set; }



    public override Response Execute()
    {
        var playback = MasterContainer.GetService <Playback>();
        var reciever = new LiveBroadcastReciever(RemoteIP, Port, new PcmCodec(), playback);

        MasterContainer.AddService(reciever);
        try
        {
            reciever.RecieveLiveBroadcast();
            return(new LiveBroadcastResponse(LiveBroadcastResults.Recieving));
        }
        catch (Exception ex)
        {
            reciever.Abort();
            return(new LiveBroadcastResponse(LiveBroadcastResults.Failed, ex.Message));
        }
    }
Пример #16
0
    public override Response Execute()
    {
        var db         = MasterContainer.GetService <IBroadcastDatabase>();
        var collisions = db.GetInterval(Broadcast.StartTime, Broadcast.EndTime);

        UploadBroadcastResult result;

        if (collisions.Length > 0)
        {
            var authorizator = MasterContainer.GetService <IAuthorizator>();
            if (authorizator.HasPermission(User, Permission.AdminBroadcasts))
            {
                foreach (var collision in collisions)
                {
                    db.Remove(collision.Id);
                }
                result = UploadBroadcastResult.Success;
            }
            else
            {
                result = UploadBroadcastResult.CollissionBlocked;
            }
        }
        else
        {
            result = UploadBroadcastResult.Success;
        }

        if (result == UploadBroadcastResult.Success)
        {
            var          store    = MasterContainer.GetService <FileStore>();
            string       fullPath = store.GenerateFullFilename(Broadcast);
            FileReciever reciever = new FileReciever(Session.Host, Port, BufferSize, fullPath);
            reciever.Start();

            Broadcast.Filename = store.GetFilename(Broadcast);
            db.Add(Broadcast);
        }

        return(new UploadBroadcastResponse(result));
    }
Пример #17
0
        private void OnRecord()
        {
            var settings = Settings.Default;

            var client      = MasterContainer.GetService <RequestSender>();
            var currentUser = MasterContainer.GetService <User>();
            var request     = new LiveBroadcastRequest(currentUser, settings.SERVER_IP, settings.BROADCAST_PORT);
            var response    = client.SendAndRecieve <LiveBroadcastResponse>(request);

            string message = null;

            if (response != null)
            {
                if (response.Result == LiveBroadcastResults.Recieving)
                {
                    rcRecorder.FrontColor = Color.Red;
                    btnRecord.Enabled     = false;

                    rcRecorder.Record();
                    streamer.StartStreaming();
                }
                else
                {
                    message = string.Format("Pøi pokusu o navázání pøipojení došlo k následující chybì:\r\n\r\n{0}.",
                                            response.Error);
                }
            }
            else
            {
                message = "Neznámá chyba";
            }

            if (message != null)
            {
                MessageBox.Show(message, "Chyba", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #18
0
 public CalendarForm()
 {
     InitializeComponent();
     client      = MasterContainer.GetService <RequestSender>();
     currentUser = MasterContainer.GetService <User>();
 }