コード例 #1
0
ファイル: ServerVdDoc.cs プロジェクト: z-saffarpour/duscusys
        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);
            }
        }
コード例 #2
0
        /// cluster engine
        public void HandleLinkCreateRequest(LitePeer peer,
                                            OperationRequest operationRequest,
                                            SendParameters sendParameters)
        {
            var req = LinkCreateMessage.Read(operationRequest.Parameters);

            //shape
            var link = new ServerBaseVdShape(req.shapeId, req.ownerId, VdShapeType.ClusterLink, (int)req.HeadType);

            _doc.AddShape(link);

            //topology
            _topology.Link(req.end1Id, req.end2Id, req.shapeId);

            _room.BroadcastReliableToRoom((byte)DiscussionEventCode.LinkCreateEvent,
                                          LinkCreateMessage.Write(req.end1Id, req.end2Id,
                                                                  req.ownerId, req.shapeId,
                                                                  _topicId, false, req.HeadType));

            EventLogger.LogAndBroadcast(new DiscCtx(Discussions.ConfigManager.ConnStr),
                                        _room,
                                        StEvent.LinkCreated,
                                        req.ownerId,
                                        req.topicId);

            //transient state until link state update, don't save
            //pendingChanges = true;
        }
コード例 #3
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;
        }
コード例 #4
0
ファイル: ServerVdDoc.cs プロジェクト: gdlprj/duscusys
        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);
            }
        }
コード例 #5
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;
        }
コード例 #6
0
ファイル: VectProcessor.cs プロジェクト: gdlprj/duscusys
        /// cluster engine 
        public void HandleLinkCreateRequest(LitePeer peer,
                                            OperationRequest operationRequest,
                                            SendParameters sendParameters)
        {
            var req = LinkCreateMessage.Read(operationRequest.Parameters);

            //shape             
            var link = new ServerBaseVdShape(req.shapeId, req.ownerId, VdShapeType.ClusterLink, (int) req.HeadType);
            _doc.AddShape(link);

            //topology
            _topology.Link(req.end1Id, req.end2Id, req.shapeId);

            _room.BroadcastReliableToRoom((byte) DiscussionEventCode.LinkCreateEvent,
                                          LinkCreateMessage.Write(req.end1Id, req.end2Id,
                                                                  req.ownerId, req.shapeId,
                                                                  _topicId, false, req.HeadType));

            EventLogger.LogAndBroadcast(new DiscCtx(Discussions.ConfigManager.ConnStr),
                                        _room,
                                        StEvent.LinkCreated,
                                        req.ownerId,
                                        req.topicId);

            //transient state until link state update, don't save 
            //pendingChanges = true;
        }
コード例 #7
0
ファイル: VectProcessor.cs プロジェクト: gdlprj/duscusys
        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;
        }
コード例 #8
0
ファイル: VectProcessor.cs プロジェクト: gdlprj/duscusys
        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;
        }