protected override void ExecuteOperation(LitePeer peer, OperationRequest operationRequest, SendParameters sendParameters) { switch (operationRequest.OperationCode) { case (byte)DiscussionOpCode.NotifyStructureChanged: HandleNotifyStructureChanged(peer, operationRequest, sendParameters); break; case (byte)DiscussionOpCode.NotifyArgPointChanged: HandleNotifyArgPointChanged(peer, operationRequest, sendParameters); break; case (byte)DiscussionOpCode.NotifyUserAccPlusMinus: HandleUserAccPlusMinus(peer, operationRequest, sendParameters); break; case (byte)DiscussionOpCode.StatsEvent: HandleStatsEvent(peer, operationRequest, sendParameters); break; case (byte)DiscussionOpCode.NotifyNameChanged: HandleNameChanged(peer, operationRequest, sendParameters); break; case (byte)DiscussionOpCode.CursorRequest: var topicId = Serializers.ReadChangedTopicId(operationRequest.Parameters); VectEditor(topicId).HandleCursorRequest(peer, operationRequest, sendParameters); break; case (byte)DiscussionOpCode.CreateShapeRequest: topicId = Serializers.ReadChangedTopicId(operationRequest.Parameters); VectEditor(topicId).HandleCreateShape(peer, operationRequest, sendParameters); break; case (byte)DiscussionOpCode.DeleteShapesRequest: topicId = Serializers.ReadChangedTopicId(operationRequest.Parameters); VectEditor(topicId).HandleDeleteShapes(peer, operationRequest, sendParameters); break; case (byte)DiscussionOpCode.UnselectAllRequest: topicId = Serializers.ReadChangedTopicId(operationRequest.Parameters); VectEditor(topicId).HandleUnselectAll(peer, operationRequest, sendParameters); break; case (byte)DiscussionOpCode.DeleteSingleShapeRequest: topicId = Serializers.ReadChangedTopicId(operationRequest.Parameters); VectEditor(topicId).HandleDeleteSingleShape(peer, operationRequest, sendParameters); break; case (byte)DiscussionOpCode.StateSyncRequest: topicId = Serializers.ReadChangedTopicId(operationRequest.Parameters); VectEditor(topicId).HandleStateSync(peer, operationRequest, sendParameters); break; case (byte)DiscussionOpCode.InitialSceneLoadRequest: topicId = Serializers.ReadChangedTopicId(operationRequest.Parameters); VectEditor(topicId).HandleInitialSceneLoad(peer, operationRequest, sendParameters); break; case (byte)DiscussionOpCode.LinkCreateRequest: topicId = Serializers.ReadChangedTopicId(operationRequest.Parameters); VectEditor(topicId).HandleLinkCreateRequest(peer, operationRequest, sendParameters); break; case (byte)DiscussionOpCode.UnclusterBadgeRequest: topicId = Serializers.ReadChangedTopicId(operationRequest.Parameters); VectEditor(topicId).HandleUnclusterBadgeRequest(peer, operationRequest, sendParameters); break; case (byte)DiscussionOpCode.ClusterBadgeRequest: topicId = Serializers.ReadChangedTopicId(operationRequest.Parameters); VectEditor(topicId).HandleClusterBadgeRequest(peer, operationRequest, sendParameters); break; case (byte)DiscussionOpCode.InkRequest: topicId = Serializers.ReadChangedTopicId(operationRequest.Parameters); VectEditor(topicId).HandleInkRequest(peer, operationRequest, sendParameters); break; case (byte)DiscussionOpCode.DEditorReport: topicId = Serializers.ReadChangedTopicId(operationRequest.Parameters); VectEditor(topicId).HandleDEditorStatsRequest(peer, operationRequest, sendParameters); break; case (byte)DiscussionOpCode.ClusterStatsRequest: topicId = Serializers.ReadChangedTopicId(operationRequest.Parameters); VectEditor(topicId).HandleClusterStatsRequest(peer, operationRequest, sendParameters); break; case (byte)DiscussionOpCode.LinkReportRequest: topicId = Serializers.ReadChangedTopicId(operationRequest.Parameters); VectEditor(topicId).HandleLinkReportRequest(peer, operationRequest, sendParameters); break; case (byte)DiscussionOpCode.BadgeViewRequest: HandleBadgeView(peer, operationRequest, sendParameters); break; case (byte)DiscussionOpCode.ExplanationModeSyncViewRequest: HandleSourceView(peer, operationRequest, sendParameters); break; case (byte)DiscussionOpCode.CommentReadRequest: HandleCommentRead(peer, operationRequest, sendParameters); break; case (byte)DiscussionOpCode.AttachLaserPointerRequest: var ptr = LaserPointer.Read(operationRequest.Parameters); VectEditor(ptr.TopicId).HandleAttachLaserPointer(peer, ptr, operationRequest, sendParameters); break; case (byte)DiscussionOpCode.DetachLaserPointerRequest: ptr = LaserPointer.Read(operationRequest.Parameters); VectEditor(ptr.TopicId).HandleDetachLaserPointer(peer, ptr, operationRequest, sendParameters); break; case (byte)DiscussionOpCode.LaserPointerMovedRequest: var ptrLoc = LaserPointer.Read(operationRequest.Parameters); VectEditor(ptrLoc.TopicId).HandleLaserPointerMoved(peer, ptrLoc, operationRequest, sendParameters); break; case (byte)DiscussionOpCode.DetachLaserPointerFromAnyTopicRequest: var userId = (int)operationRequest.Parameters[(byte)DiscussionParamKey.UserId]; DetachLaserPointerFormAnyTopic(peer, userId); break; case (byte)DiscussionOpCode.ImageViewerManipulateRequest: var mat = ImageViewerMatrix.Read(operationRequest.Parameters); VectEditor(mat.TopicId).HandleManipulateImageViewer(peer, mat, operationRequest, sendParameters); break; case (byte)DiscussionOpCode.ImageViewerStateRequest: var sr = ImageViewerStateRequest.Read(operationRequest.Parameters); VectEditor(sr.TopicId).HandleImageViewerStateRequest(peer, sr, operationRequest, sendParameters); break; case (byte)DiscussionOpCode.BrowserScrollChanged: var browserScroll = BrowserScrollPosition.Read(operationRequest.Parameters); VectEditor(browserScroll.topicId).HandleBrowserScrollSubmitted(peer, browserScroll, operationRequest, sendParameters); break; case (byte)DiscussionOpCode.GetBrowserScrollPos: var browserScrollReq = BrowserScrollPositionRequest.Read(operationRequest.Parameters); VectEditor(browserScrollReq.topicId).HandleBrowserScrollRequested(peer, operationRequest, sendParameters); break; case (byte)DiscussionOpCode.PdfScrollChanged: var pdfScroll = PdfScrollPosition.Read(operationRequest.Parameters); VectEditor(pdfScroll.topicId).HandlePdfScrollSubmitted(peer, pdfScroll, operationRequest, sendParameters); break; case (byte)DiscussionOpCode.GetPdfScrollPos: var pdfScrollReq = PdfScrollPositionRequest.Read(operationRequest.Parameters); VectEditor(pdfScrollReq.topicId).HandlePdfScrollRequested(peer, operationRequest, sendParameters); break; default: base.ExecuteOperation(peer, operationRequest, sendParameters); break; } }
public void OnEvent(EventData eventData) { switch (eventData.Code) { case (byte)LiteEventCode.Join: int[] actNrs = (int[])eventData.Parameters[(byte)ParameterKey.Actors]; int ActorNr = (int)eventData.Parameters[(byte)ParameterKey.ActorNr]; var actProps = (Hashtable)eventData.Parameters[(byte)ParameterKey.ActorProperties]; Console.WriteLine("Join event actors.len={0}", actNrs.Length); List <int> unknownPeersNrs = new List <int>(); for (int i = 0; i < actNrs.Length; i++) { if (!usersOnline.ContainsKey(actNrs[i])) { if (!unknownPeersNrs.Contains(actNrs[i])) { unknownPeersNrs.Add(actNrs[i]); } } } requestPeersInfo(unknownPeersNrs.ToArray()); DbgPrintOnlineList(); break; case (byte)EventCode.Leave: actNrs = (int[])eventData.Parameters[(byte)ParameterKey.Actors]; int leftActNr = (int)eventData.Parameters[(byte)ParameterKey.ActorNr]; Console.WriteLine("Leave event, actors.len={0}", actNrs.Length); if (usersOnline.ContainsKey(leftActNr)) { if (userLeaves != null) { DiscUser leaving = usersOnline[leftActNr]; userLeaves(leaving); } usersOnline.Remove(leftActNr); } DbgPrintOnlineList(); break; case (byte)DiscussionEventCode.InstantUserPlusMinus: if (smbdLeaved != null) { smbdLeaved(); } break; case (byte)DiscussionEventCode.StructureChanged: int initiater = (int)eventData.Parameters[(byte)DiscussionParamKey.UserId]; int devType = (int)eventData.Parameters[(byte)DiscussionParamKey.DeviceType]; if (eventData.Parameters.ContainsKey((byte)DiscussionParamKey.ForceSelfNotification)) { //topic updated if (onStructChanged != null) { onStructChanged(Serializers.ReadChangedTopicId(eventData.Parameters), initiater, (DeviceType)devType); } } else if (initiater != -1 && initiater != localUsr.ActNr) { if (onStructChanged != null) { onStructChanged(Serializers.ReadChangedTopicId(eventData.Parameters), initiater, (DeviceType)devType); } } break; case (byte)DiscussionEventCode.ArgPointChanged: var changeType = PointChangedType.Modified; int topicId; int personId; int argPointId = Serializers.ReadChangedArgPoint(eventData.Parameters, out changeType, out topicId, out personId); if (argPointChanged != null) { argPointChanged(argPointId, topicId, changeType, personId); } break; case (byte)DiscussionEventCode.UserAccPlusMinus: if (userAccPlusMinus != null) { userAccPlusMinus(); } break; case (byte)DiscussionEventCode.StatsEvent: if (onStatsEvent != null) { StEvent e; int userId = -1; int discussionId = -1; int statsTopicId = -1; DeviceType devTyp; Serializers.ReadStatEventParams(eventData.Parameters, out e, out userId, out discussionId, out statsTopicId, out devTyp); onStatsEvent(e, userId, discussionId, statsTopicId, devTyp); } break; case (byte)DiscussionEventCode.CursorEvent: if (cursorEvent != null) { cursorEvent(CursorEvent.Read(eventData.Parameters)); } break; case (byte)DiscussionEventCode.CreateShapeEvent: if (createShapeEvent != null) { createShapeEvent(CreateShape.Read(eventData.Parameters)); } break; case (byte)DiscussionEventCode.UnselectAllEvent: if (unselectAll != null) { unselectAll(UnselectAllEvent.Read(eventData.Parameters)); } break; case (byte)DiscussionEventCode.DeleteSingleShapeEvent: if (deleteSingleShape != null) { deleteSingleShape(DeleteSingleShapeEvent.Read(eventData.Parameters)); } break; case (byte)DiscussionEventCode.ApplyPointEvent: if (applyPoint != null) { applyPoint(PointMove.Read(eventData.Parameters)); } break; case (byte)DiscussionEventCode.StateSyncEvent: if (syncStateEvent != null) { syncStateEvent(ShapeState.Read(eventData.Parameters)); } break; case (byte)DiscussionEventCode.LinkCreateEvent: if (onLinkCreateEvent != null) { onLinkCreateEvent(LinkCreateMessage.Read(eventData.Parameters)); } break; case (byte)DiscussionEventCode.UnclusterBadgeEvent: if (onUnclusterBadgeEvent != null) { onUnclusterBadgeEvent(UnclusterBadgeMessage.Read(eventData.Parameters)); } break; case (byte)DiscussionEventCode.ClusterBadgeEvent: if (onClusterBadgeEvent != null) { onClusterBadgeEvent(ClusterBadgeMessage.Read(eventData.Parameters)); } break; case (byte)DiscussionEventCode.InkEvent: if (inkEvent != null) { inkEvent(InkMessage.Read(eventData.Parameters)); } break; case (byte)DiscussionEventCode.SceneLoadingDone: if (loadingDoneEvent != null) { loadingDoneEvent(); } break; case (byte)DiscussionEventCode.DEditorReportEvent: if (dEditorReportResponse != null) { dEditorReportResponse(DEditorStatsResponse.Read(eventData.Parameters)); } break; case (byte)DiscussionEventCode.ClusterStatsEvent: if (clusterStatsResponse != null) { if (eventData.Parameters == null || eventData.Parameters.Count() == 0) { clusterStatsResponse(default(ClusterStatsResponse), false); } else { clusterStatsResponse(ClusterStatsResponse.Read(eventData.Parameters), true); } } break; case (byte)DiscussionEventCode.LinkStatsEvent: if (linkStatsResponseEvent != null) { if (eventData.Parameters == null || eventData.Parameters.Count() == 0) { linkStatsResponseEvent(default(LinkReportResponse), false); } else { linkStatsResponseEvent(LinkReportResponse.Read(eventData.Parameters), true); } } break; case (byte)DiscussionEventCode.BadgeViewEvent: if (onBadgeViewRequest != null) { onBadgeViewRequest(BadgeViewMessage.Read(eventData.Parameters)); } break; case (byte)DiscussionEventCode.SourceViewEvent: if (onSourceViewRequest != null) { onSourceViewRequest(ExplanationModeSyncMsg.Read(eventData.Parameters)); } break; case (byte)DiscussionEventCode.CommentReadEvent: if (onCommentRead != null) { onCommentRead(CommentsReadEvent.Read(eventData.Parameters)); } break; case (byte)DiscussionEventCode.AttachLaserPointerEvent: if (onAttachLaserPointer != null) { onAttachLaserPointer(LaserPointer.Read(eventData.Parameters)); } break; case (byte)DiscussionEventCode.DetachLaserPointerEvent: if (onDetachLaserPointer != null) { onDetachLaserPointer(LaserPointer.Read(eventData.Parameters)); } break; case (byte)DiscussionEventCode.LaserPointerMovedEvent: if (onLaserPointerMoved != null) { onLaserPointerMoved(LaserPointer.Read(eventData.Parameters)); } break; case (byte)DiscussionEventCode.ImageViewerManipulatedEvent: if (onImageViewerManipulated != null) { onImageViewerManipulated(ImageViewerMatrix.Read(eventData.Parameters)); } break; case (byte)DiscussionEventCode.BrowserScrollChangedEvent: if (onBrowserScroll != null) { onBrowserScroll(BrowserScrollPosition.Read(eventData.Parameters)); } break; case (byte)DiscussionEventCode.PdfScrollChangedEvent: if (onPdfScroll != null) { onPdfScroll(PdfScrollPosition.Read(eventData.Parameters)); } break; default: Console.WriteLine("Unhandled event " + eventData.Code); break; } }