/// <summary> /// 重新所有笔的状态(以及缓存的所有答案) /// </summary> public void ResetStatus() { FlowManage.ClearAnswer(); foreach (var studentId in APP.StudySession.StudentIds) { var pen = GetPen(studentId); if (pen != null) { pen.ResetStatus(); } } }
/// <summary> /// Udp接收到客户端数据事件 /// </summary> /// <param name="connection"></param> /// <param name="server"></param> public void UdpHandleDataReceived(UdpServer server, UdpState udpState) { var type = udpState.Buffer[0]; if (type != 0x55) { return; } var packet_type = udpState.Buffer.GetRange(2, 1)[0]; switch (packet_type) { case 0x01: //坐标 { if (APP.StudySession.IsAnswer || APP.StudySession.IsSelfJudgment) { var pendot = udpState.Buffer.ToStruct <Packs.Pendot>(); if (pendot.penid == 0) { pendot.penid = 9; //这是我专用测试使用 } var pen = CreateOrGetPen(pendot.penid); if (APP.StudySession.HasStudy(pen.StudentId) == false) { break; } FlowManage.RunFlows(new PenKey(pendot.penid)); pen.SetWriteing(true); QueueManage.Instance.AddPendot(pendot); } } break; case 0x02: //心跳 { var heartbeat = udpState.Buffer.ToStruct <HeartbeatPack>(); if (heartbeat.penid == 0) { heartbeat.penid = 9; //这是我专用测试使用 } var pen = CreateOrGetPen(heartbeat.penid); pen.BindDevice(udpState.IpEndPoint.Address, heartbeat.deviceid); //10秒左右更新一次 } break; case 0x03: //按键 { //原样应答 server.Send(udpState.Buffer, udpState.IpEndPoint); if (APP.StudySession.IsAnswer || APP.StudySession.IsSelfJudgment) { var problem = udpState.Buffer.ToStruct <Packs.Problem>(); if (problem.penid == 0) { problem.penid = 9; //这是我专用测试使用 } var pen = CreateOrGetPen(problem.penid); if (APP.StudySession.HasStudy(pen.StudentId) == false) { break; } FlowManage.RunFlows(new PenKey(problem)); } } break; } }