Exemple #1
0
        public void HandleBadgeCreated(int argPointId,
                                       LitePeer peer,
                                       OperationRequest operationRequest,
                                       SendParameters sendParameters)
        {
            var ctx = new DiscCtx(Discussions.ConfigManager.ConnStr);
            var ap  = ctx.ArgPoint.FirstOrDefault(ap0 => ap0.Id == argPointId);

            if (ap == null)
            {
                throw new NotSupportedException("cannot find badge in db!");
            }

            var badgeSh = new ServerBaseVdShape(_doc.BadgeIdGen.NextId(), ap.Person.Id, VdShapeType.Badge, argPointId);

            _doc.AddShape(badgeSh);
            _topology.CreateBadge(badgeSh.Id());

            //get position
            double x;
            double y;

            GetBadgeSmartLocation(ap.Person.Id, out x, out y);

            //set initial badge state
            var st = new ShapeState(VdShapeType.Badge,
                                    ap.Person.Id,
                                    badgeSh.Id(),
                                    null,
                                    null,
                                    new double[] { x, y },
                                    _topicId);

            badgeSh.ApplyState(st);

            var badgeCreateEv = CreateShape.Write(ap.Person.Id, badgeSh.Id(),
                                                  VdShapeType.Badge,
                                                  st.doubles[0], st.doubles[1], false,
                                                  argPointId, _topicId);

            //include self, badge is created in private board, and if our public board is open, we want to play new badge
            _room.Broadcast(peer,
                            badgeCreateEv,
                            sendParameters,
                            (byte)DiscussionEventCode.CreateShapeEvent,
                            BroadcastTo.RoomAll);

            _pendingChanges = true;
        }
Exemple #2
0
        public void Read(BinaryReader annotation)
        {
            if (annotation != null)
            {
                _badgeIdGen = new BadgeShapeIdGenerator(annotation.ReadInt32());
            }
            else
            {
                _badgeIdGen = new BadgeShapeIdGenerator();
            }

            if (annotation == null)
            {
                return;
            }

            readInk(annotation);

            var numShapes = annotation.ReadInt32();

            for (var i = 0; i < numShapes; i++)
            {
                var sh = new ServerBaseVdShape(annotation);
                _shapeIdToShape.Add(sh.Id(), sh);
            }
        }
Exemple #3
0
        public void Read(BinaryReader annotation)
        {
            if (annotation != null)
                _badgeIdGen = new BadgeShapeIdGenerator(annotation.ReadInt32());
            else
                _badgeIdGen = new BadgeShapeIdGenerator();

            if (annotation == null)
                return;

            readInk(annotation);

            var numShapes = annotation.ReadInt32();
            for (var i = 0; i < numShapes; i++)
            {
                var sh = new ServerBaseVdShape(annotation);
                _shapeIdToShape.Add(sh.Id(), sh);
            }
        }
Exemple #4
0
        public void HandleCreateShape(LitePeer peer,
                                      OperationRequest operationRequest,
                                      SendParameters sendParameters)
        {
            var req = CreateShape.Read(operationRequest.Parameters);

            var newSh = new ServerBaseVdShape(req.shapeId, req.ownerId, req.shapeType, req.tag);

            switch (req.shapeType)
            {
            case VdShapeType.Cluster:
                _topology.CreateCluster(newSh.Id());
                _doc.AddShape(newSh);
                break;

            case VdShapeType.FreeForm:
                _doc.AddShape(newSh);
                EventLogger.LogAndBroadcast(
                    new DiscCtx(Discussions.ConfigManager.ConnStr),
                    _room,
                    StEvent.FreeDrawingCreated,
                    req.ownerId,
                    _topicId);
                break;

            default:
                _doc.AddShapeAndLock(newSh);
                break;
            }

            _room.Broadcast(peer,
                            operationRequest,
                            sendParameters,
                            (byte)DiscussionEventCode.CreateShapeEvent,
                            BroadcastTo.RoomExceptSelf);
            //don't include self, we play shape creation locally without continuation

            _pendingChanges = true;
        }
Exemple #5
0
        public void HandleBadgeCreated(int argPointId,
                                       LitePeer peer,
                                       OperationRequest operationRequest,
                                       SendParameters sendParameters)
        {
            var ctx = new DiscCtx(Discussions.ConfigManager.ConnStr);
            var ap = ctx.ArgPoint.FirstOrDefault(ap0 => ap0.Id == argPointId);
            if (ap == null)
                throw new NotSupportedException("cannot find badge in db!");

            var badgeSh = new ServerBaseVdShape(_doc.BadgeIdGen.NextId(), ap.Person.Id, VdShapeType.Badge, argPointId);
            _doc.AddShape(badgeSh);
            _topology.CreateBadge(badgeSh.Id());

            //get position
            double x;
            double y;
            GetBadgeSmartLocation(ap.Person.Id, out x, out y);

            //set initial badge state 
            var st = new ShapeState(VdShapeType.Badge,
                                    ap.Person.Id,
                                    badgeSh.Id(),
                                    null,
                                    null,
                                    new double[] {x, y},
                                    _topicId);
            badgeSh.ApplyState(st);

            var badgeCreateEv = CreateShape.Write(ap.Person.Id, badgeSh.Id(),
                                                  VdShapeType.Badge,
                                                  st.doubles[0], st.doubles[1], false,
                                                  argPointId, _topicId);

            //include self, badge is created in private board, and if our public board is open, we want to play new badge
            _room.Broadcast(peer,
                            badgeCreateEv,
                            sendParameters,
                            (byte) DiscussionEventCode.CreateShapeEvent,
                            BroadcastTo.RoomAll);

            _pendingChanges = true;
        }
Exemple #6
0
        public void HandleCreateShape(LitePeer peer,
                                      OperationRequest operationRequest,
                                      SendParameters sendParameters)
        {
            var req = CreateShape.Read(operationRequest.Parameters);

            var newSh = new ServerBaseVdShape(req.shapeId, req.ownerId, req.shapeType, req.tag);

            switch (req.shapeType)
            {
                case VdShapeType.Cluster:
                    _topology.CreateCluster(newSh.Id());
                    _doc.AddShape(newSh);
                    break;
                case VdShapeType.FreeForm:
                    _doc.AddShape(newSh);                    
                    EventLogger.LogAndBroadcast(
                        new DiscCtx(Discussions.ConfigManager.ConnStr),
                        _room,
                        StEvent.FreeDrawingCreated,
                        req.ownerId,
                        _topicId);                    
                    break;
                default:
                    _doc.AddShapeAndLock(newSh);
                    break;
            }

            _room.Broadcast(peer,
                            operationRequest,
                            sendParameters,
                            (byte) DiscussionEventCode.CreateShapeEvent,
                            BroadcastTo.RoomExceptSelf);
                //don't include self, we play shape creation locally without continuation

            _pendingChanges = true;
        }