Beispiel #1
0
        public object Post([FromUri] Guid documentId, [FromUri] Guid clientId, [FromBody] DocumenChange change)
        {
            var documentSession = documentSessionsRepository.GetOrLoad(documentId);

            documentSession.Change(clientId, change);
            return(documentSession.GetState(clientId, change.Revision));
        }
        public override async Task OnOpenAsync()
        {
            try
            {
                clientId        = Guid.Parse(Arguments["clientId"]);
                documentId      = Guid.Parse(Arguments["documentId"]);
                documentSession = documentSessionsRepository.GetOrLoad(documentId);

                DocumentState state;
                do
                {
                    state = documentSession.GetState(clientId, revision);
                    await SendText(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(state)), true);

                    revision = state.Revision;
                } while (state.Operations.Length > 0);

                documentSession.Register(clientId, this);
            }
            catch (Exception e)
            {
                logger.Warning("Error on open websocket", e);
                throw;
            }
        }