public void UpdateModel(ShapeModel clientModel) { clientModel.LastUpdatedBy = Context.ConnectionId; // 排除自己,在我们的广播器中更新形状模型 //Clients.AllExcept(clientModel.LastUpdatedBy).updateShape(clientModel); // 更新定时广播器形状 broadcaster.UpdateShape(clientModel); }
public Broadcaster() { // 保存我们的hub上下文,以便我们可以轻松地使用它发送到它的连接客户端 _hubContext = GlobalHost.ConnectionManager.GetHubContext <MoveShapeHub>(); _model = new ShapeModel(); _modelUpdated = false; // Start the broadcast loop _broadcastLoop = new Timer( BroadcastShape, null, BroadcastInterval, BroadcastInterval); }
/// <summary> /// 更改形状 /// </summary> /// <param name="clientModel"></param> public void UpdateShape(ShapeModel clientModel) { _model = clientModel; _modelUpdated = true; }