incubator-bluesky-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject svn commit: r823467 [6/6] - in /incubator/bluesky/trunk/RealClass/Teacher: ./ src/ src/pic/
Date Fri, 09 Oct 2009 08:58:44 GMT
Added: incubator/bluesky/trunk/RealClass/Teacher/src/tcpcomm.cpp
URL: http://svn.apache.org/viewvc/incubator/bluesky/trunk/RealClass/Teacher/src/tcpcomm.cpp?rev=823467&view=auto
==============================================================================
--- incubator/bluesky/trunk/RealClass/Teacher/src/tcpcomm.cpp (added)
+++ incubator/bluesky/trunk/RealClass/Teacher/src/tcpcomm.cpp Fri Oct  9 08:58:41 2009
@@ -0,0 +1,66 @@
+// TCPComm.cpp: implementation of the CTCPComm class.
+
+#include "stdafx.h"
+#include "asyncsocketex.h"
+#include "tcpcomm.h"
+#include "tcppollthread.h"
+
+CTCPComm::CTCPComm()
+{
+
+	m_pThread = 0;
+}
+
+CTCPComm::~CTCPComm()
+{
+
+}
+
+int CTCPComm::OnPollThreadError(int status)
+{
+	return -1;
+}
+
+bool CTCPComm::Init()
+{
+
+	if (m_pThread)
+	{
+		m_pThread->Stop();
+		return true;
+	}
+
+	m_pThread = new CTCPPollThread(this);
+
+	if (m_pThread)
+		return true;
+
+	return false;
+}
+
+int CTCPComm::Start()
+{
+	if (m_pThread == 0)
+	{
+		return -1;
+	}
+	return m_pThread->Start();
+}
+
+bool CTCPComm::IsPolling()
+{
+	if (m_pThread == 0)
+	{
+		return false;
+	}
+	return m_pThread->IsRunning();
+}
+
+void CTCPComm::Stop()
+{
+	if (m_pThread)
+	{
+		m_pThread->Stop();
+	}
+
+}

Added: incubator/bluesky/trunk/RealClass/Teacher/src/tcpcomm.h
URL: http://svn.apache.org/viewvc/incubator/bluesky/trunk/RealClass/Teacher/src/tcpcomm.h?rev=823467&view=auto
==============================================================================
--- incubator/bluesky/trunk/RealClass/Teacher/src/tcpcomm.h (added)
+++ incubator/bluesky/trunk/RealClass/Teacher/src/tcpcomm.h Fri Oct  9 08:58:41 2009
@@ -0,0 +1,28 @@
+// TCPComm.h: interface for the CTCPComm class.
+
+#if !defined(TCPCOMM_H)
+#define TCPCOMM_H
+
+class CTCPPollThread;
+class CTCPComm
+{
+	friend class CTCPPollThread;
+public:
+	void Stop();
+	bool IsPolling();
+	int Start();
+	virtual bool Init();
+	CTCPComm();
+	virtual ~CTCPComm();
+
+protected:
+	virtual void OnPollThreadStep() = 0;
+	virtual int OnPollThreadError(int status);
+	virtual int PolledSocket() = 0;
+	virtual int Poll() = 0;
+
+private:
+	CTCPPollThread *m_pThread;
+};
+
+#endif // !defined(TCPCOMM_H)

Added: incubator/bluesky/trunk/RealClass/Teacher/src/tcppollthread.cpp
URL: http://svn.apache.org/viewvc/incubator/bluesky/trunk/RealClass/Teacher/src/tcppollthread.cpp?rev=823467&view=auto
==============================================================================
--- incubator/bluesky/trunk/RealClass/Teacher/src/tcppollthread.cpp (added)
+++ incubator/bluesky/trunk/RealClass/Teacher/src/tcppollthread.cpp Fri Oct  9 08:58:41 2009
@@ -0,0 +1,83 @@
+#include "tcppollthread.h"
+#include "tcpcomm.h"
+
+CTCPPollThread::CTCPPollThread(CTCPComm* pcomm)
+{
+	m_pcomm = pcomm;
+	stop = false;
+}
+
+CTCPPollThread::~CTCPPollThread()
+{
+	Stop();
+}
+
+int CTCPPollThread::Start()
+{
+	if (JThread::IsRunning())
+		return -1;
+
+	if (!stopmutex.IsInitialized())
+	{
+		if (stopmutex.Init() < 0)
+			return -1;
+	}
+	stop = false;
+	if (JThread::Start() < 0)
+		return -1;
+	return 0;
+}
+
+void CTCPPollThread::Stop()
+{
+	if (!IsRunning())
+		return;
+
+	stopmutex.Lock();
+	stop = true;
+	stopmutex.Unlock();
+
+	if (JThread::IsRunning())
+	{
+		JThread::Kill();
+	}
+	stop = false;
+}
+
+void *CTCPPollThread::Thread()
+{
+	JThread::ThreadStarted();
+
+	int status;
+	bool stopthread;
+
+	stopmutex.Lock();
+	stopthread = stop;
+	stopmutex.Unlock();
+	while (!stopthread)
+	{
+		status = m_pcomm->Poll();
+		if (status < 0)
+		{
+			stopthread = 0;
+			m_pcomm->OnPollThreadError(status);
+		}
+		else
+		{
+			status = m_pcomm->PolledSocket();
+			if (status < 0)
+			{
+				stopthread = true;
+				m_pcomm->OnPollThreadError(status);
+			}
+			else
+			{
+				m_pcomm->OnPollThreadStep();
+				stopmutex.Lock();
+				stopthread = stop;
+				stopmutex.Unlock();
+			}
+		}
+	}
+	return 0;
+}

Added: incubator/bluesky/trunk/RealClass/Teacher/src/tcppollthread.h
URL: http://svn.apache.org/viewvc/incubator/bluesky/trunk/RealClass/Teacher/src/tcppollthread.h?rev=823467&view=auto
==============================================================================
--- incubator/bluesky/trunk/RealClass/Teacher/src/tcppollthread.h (added)
+++ incubator/bluesky/trunk/RealClass/Teacher/src/tcppollthread.h Fri Oct  9 08:58:41 2009
@@ -0,0 +1,25 @@
+#ifndef CTCPPOLLTHREAD_H
+
+#define CTCPPOLLTHREAD_H
+
+#include "jthread.h"
+#include "jmutex.h"
+
+class CTCPComm;
+class CTCPPollThread: private JThread
+{
+	friend class CTCPComm;
+public:
+	CTCPPollThread(CTCPComm* pcomm);
+	~CTCPPollThread();
+	int Start();
+	void Stop();
+private:
+	void *Thread();
+
+	bool stop;
+	JMutex stopmutex;
+	CTCPComm *m_pcomm;
+};
+
+#endif // CTCPPOLLTHREAD_H

Added: incubator/bluesky/trunk/RealClass/Teacher/src/trcclient.hh
URL: http://svn.apache.org/viewvc/incubator/bluesky/trunk/RealClass/Teacher/src/trcclient.hh?rev=823467&view=auto
==============================================================================
--- incubator/bluesky/trunk/RealClass/Teacher/src/trcclient.hh (added)
+++ incubator/bluesky/trunk/RealClass/Teacher/src/trcclient.hh Fri Oct  9 08:58:41 2009
@@ -0,0 +1,244 @@
+#ifndef _TRCCLIENT_H
+#define _TRCCLIENT_H
+
+#define limitbit 200
+
+#include<stdio.h>
+#include<string.h>
+
+typedef unsigned long DWORD;
+struct CRCLMSG
+{
+	DWORD rclType;
+	DWORD msglen;
+	char msg[10000];
+};
+
+struct CClientInfo
+{
+	DWORD ClientID;
+	char ClientName[limitbit];
+	DWORD IsFocus;
+};
+
+//ID : 5000
+struct CRCLTeacherLogin
+{
+	char TeacherName[limitbit];
+	char TeacherPass[16];
+	char TeacherIP[16];
+
+};
+
+struct CGroupInfo
+{
+	DWORD GroupID;
+	char GroupName[128];
+	char TeacherName[limitbit];
+};
+
+struct CRCLUserClassInfo
+{
+	char ClassName[128];
+};
+
+//ID : 5001
+struct CRCLTeacherLoginR
+{
+	DWORD ResponseType;
+	DWORD TeacherID;
+	DWORD ClassInfoReturn;
+	DWORD ClassInfoCount;
+	CRCLUserClassInfo ClassInfo[16];
+};
+
+//ID : 5030
+struct CRCLTeacherLogout
+{
+	DWORD TeacherID;
+};
+
+//ID : 10000
+struct CRCLCreateGroup
+{
+	DWORD TeacherID;
+	char GroupName[128];
+	DWORD CAPort;
+	DWORD CVPort;
+};
+
+//ID : 10001
+struct CRCLCreateGroupR
+{
+	DWORD ResponseType;
+	DWORD GroupID;
+	char MCUIP[16];
+	DWORD TAPort;
+	DWORD TVPort;
+	DWORD TSPort;
+};
+
+struct TRCDestoryGroup
+{
+	int TeacherID;
+	int GroupID;
+};
+
+struct TRCDestoryGroupR
+{
+	int ResponseType;
+};
+
+struct TSState
+{
+	int ClientID;
+	char ClientN[limitbit];
+	int AVMode;
+};
+
+//ID : 10022
+struct CRCLClientJoinInGroupRAll
+{
+	CClientInfo ClientInfo;
+};
+
+//ID : 10032
+struct CRCLClientLeaveGroupRAll
+{
+	CClientInfo ClientInfo;
+};
+
+//ID : 10042
+struct CRCLMCULeaveGroupRAll
+{
+	DWORD GroupID;
+};
+
+//ID : 1000
+struct CRCLTeacherTextBroadcast
+{
+	DWORD ClientID;
+	DWORD GroupID;
+	DWORD InfoLength;
+	char Info[1024];
+};
+
+//ID : 1001
+struct CRCLTeacherTextBroadcastR
+{
+	char TeacherName[limitbit];
+	DWORD InfoLength;
+	char Info[1024];
+};
+
+//ID : 1012
+struct CRCLClientApplyFocusRToTM
+{
+	DWORD FocusClientID;
+};
+
+//ID : 1022
+struct CRCLClientDestroyFocusRToTM
+{
+	DWORD FocusClientID;
+};
+
+//ID : 1031
+struct CRCLClientTextBroadcastR
+{
+	char ClientName[limitbit];
+	DWORD InfoLength;
+	char Info[1024];
+};
+
+//ID : 1050
+struct CRCLTeacherAllowClientFocus
+{
+	DWORD TeacherID;
+	DWORD ClientID;
+	DWORD GroupID;
+};
+
+//ID : 1051
+struct CRCLTeacherAllowClientFocusR
+{
+	DWORD ResponseType;
+	DWORD ClientID;
+};
+
+//ID : 1060
+struct CRCLTeacherCancelClientFocus
+{
+	DWORD TeacherID;
+	DWORD ClientID;
+	DWORD GroupID;
+};
+
+//ID : 1061
+struct CRCLTeacherCancelClientFocusR
+{
+	DWORD ResponseType;
+	DWORD ClientID;
+};
+
+//ID : 1070
+struct CRCLTeacherGetClientList
+{
+	DWORD TeacherID;
+	DWORD RoomID;
+};
+
+//ID : 1071
+struct CRCLTeacherGetClientListR
+{
+	DWORD ResponseType;
+	DWORD ClientNum;
+	CClientInfo ClientList[1024];
+};
+
+//ID:1080
+struct CRCLTeacherSwitchMode
+{
+	DWORD GroupID;
+	DWORD ModeType;
+};
+struct CRCLTeacherSwitchModeR
+{
+	DWORD ModeType;
+};
+
+//ID:1090
+struct CRCLTeacherIfAllowChat
+{
+	DWORD GroupID;
+	DWORD Check;
+};
+//ID:1091
+struct CRCLTeacherIfAllowChatR
+{
+	DWORD ResponseType;
+};
+
+struct TPara
+{
+	char LocalIP[50];
+	char MCUIP[50];
+	char StudentN[30];
+	char PassWord[30];
+	char TeacherN[30];
+	char CourseN[50];
+	DWORD TeacherID;
+	int GroupID;
+
+	int TAPort;
+	int TVPort;
+	int TscrPort;
+	int SAPort;
+	int SVPort;
+
+	char *CenterIP;
+	int CenterPort;
+
+};
+
+#endif



Mime
View raw message