OSDN Git Service

reset brain memory
authorU-Break-VAIO\Break <Break@Break-VAIO.(none)>
Thu, 22 Nov 2012 15:20:06 +0000 (00:20 +0900)
committerU-Break-VAIO\Break <Break@Break-VAIO.(none)>
Thu, 22 Nov 2012 15:20:06 +0000 (00:20 +0900)
39 files changed:
.gitignore
common/CClientConnection.cpp
common/CClientConnection.h
common/CInputWave.cpp
common/CInputWave.h
common/COutputWave.cpp
common/COutputWave.h
common/CRingBuffer.h
common/CServerConnection.cpp
common/CServerConnection.h
common/CServerSocket.cpp
common/CServerSocket.h
common/CSocket.cpp
common/CSocket.h
common/CThread.cpp
common/CThread.h
common/CWaveData.cpp
common/CWaveData.h
common/Data.h
common/Environment.h
read me.txt
vc2010_client/vc2010_client.sln
vc2010_client/vc2010_client/CClient.cpp
vc2010_client/vc2010_client/CClient.h
vc2010_client/vc2010_client/CClientModel.cpp
vc2010_client/vc2010_client/CClientModel.h
vc2010_client/vc2010_client/CClientUI.cpp
vc2010_client/vc2010_client/CClientUI.h
vc2010_client/vc2010_client/main.cpp
vc2010_client/vc2010_client/vc2010_client.vcxproj
vc2010_server/vc2010_server.sln
vc2010_server/vc2010_server/CServer.cpp
vc2010_server/vc2010_server/CServer.h
vc2010_server/vc2010_server/CServerInput.cpp
vc2010_server/vc2010_server/CServerInput.h
vc2010_server/vc2010_server/CServerModel.cpp
vc2010_server/vc2010_server/CServerModel.h
vc2010_server/vc2010_server/main.cpp
vc2010_server/vc2010_server/vc2010_server.vcxproj

index 549ce04..c1ef1ea 100644 (file)
@@ -1,11 +1,11 @@
-Debug/
-Release/
-ipch
-*.suo
-*.dll
-*.lib
-*.sdf
-*.opensdf
-*.filters
-*.user
-
+Debug/\r
+Release/\r
+ipch\r
+*.suo\r
+*.dll\r
+*.lib\r
+*.sdf\r
+*.opensdf\r
+*.filters\r
+*.user\r
+\r
index 17b393a..c177987 100644 (file)
-#include "CClientConnection.h"
-
-////////////////////////////////////////////////////////////////////////////////
-// \83R\83\93\83X\83g\83\89\83N\83^
-////////////////////////////////////////////////////////////////////////////////
-CClientConnection::CClientConnection()
-{
-       m_isLogin = false;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \83f\83X\83g\83\89\83N\83^
-////////////////////////////////////////////////////////////////////////////////
-CClientConnection::~CClientConnection()
-{
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// initialize
-////////////////////////////////////////////////////////////////////////////////
-bool CClientConnection::initialize()
-{
-       CSocket::initialize();
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// send
-////////////////////////////////////////////////////////////////////////////////
-bool CClientConnection::send(const CommunicationData* in_pCommunicationData)
-{
-       // \83T\83C\83Y\82Í\8c\88\82ß\91Å\82¿
-       if(::send(m_Socket, reinterpret_cast<const char*>(in_pCommunicationData), MAX_COMMUNICATION_DATA_LENGTH, 0) == SOCKET_ERROR){
-               return false;
-       }
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// receive
-////////////////////////////////////////////////////////////////////////////////
-bool CClientConnection::receive(CommunicationData** out_ppCommunicationData)
-{
-       if(m_Buffer.empty()){
-               return false;
-       }
-
-       *out_ppCommunicationData = reinterpret_cast<CommunicationData*>(m_Buffer.getReadPointer()->m_Buffer);
-       m_Buffer.nextReadBuffer();
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// login
-////////////////////////////////////////////////////////////////////////////////
-bool CClientConnection::login(const char* in_pLoginName)
-{
-       CommunicationData a_SendData;
-       a_SendData.m_DataType = 'i';
-       strcpy(a_SendData.m_Data.m_LoginData.m_Name, in_pLoginName);
-       send(&a_SendData);
-
-       // \82±\82Ì\83t\83\89\83O\82Í\8eó\90M\83\81\83b\83Z\81[\83W\82ð\8am\82©\82ß\82Ä\82©\82ç\95Ï\8dX\82·\82é\82×\82«
-       m_isLogin = true;
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// logout
-////////////////////////////////////////////////////////////////////////////////
-bool CClientConnection::logout()
-{
-       CommunicationData a_SendData;
-       a_SendData.m_DataType = 'o';
-       send(&a_SendData);
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \8dÀ\95W\8eæ\93¾
-////////////////////////////////////////////////////////////////////////////////
-bool CClientConnection::requestPosition()
-{
-       CommunicationData a_SendData;
-       a_SendData.m_DataType = 'p';
-       send(&a_SendData);
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \88Ú\93®
-////////////////////////////////////////////////////////////////////////////////
-bool CClientConnection::requestMove(char in_Direction)
-{
-       CommunicationData a_SendData;
-       a_SendData.m_DataType = 'a';
-       a_SendData.m_Data.m_ActionCommand.m_CommandType = in_Direction;
-       send(&a_SendData);
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \89¹\90º\91\97\90M
-////////////////////////////////////////////////////////////////////////////////
-bool CClientConnection::sendVoice(char* in_pVoice, int in_Length, bool in_isEnd)
-{
-       CommunicationData a_SendData;
-
-       if(sizeof(a_SendData.m_Data.m_Voice.m_Stream) < in_Length){
-               return false;
-       }
-
-       a_SendData.m_DataType = 'v';
-       for(int i = 0; i < in_Length; i++){
-               a_SendData.m_Data.m_Voice.m_Stream[i] = in_pVoice[i];
-       }
-       a_SendData.m_Data.m_Voice.m_Length = in_Length;
-       a_SendData.m_Data.m_Voice.m_isEnd = in_isEnd;
-       send(&a_SendData);
-       return true;
-}
+#include "CClientConnection.h"\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83R\83\93\83X\83g\83\89\83N\83^\r
+////////////////////////////////////////////////////////////////////////////////\r
+CClientConnection::CClientConnection()\r
+{\r
+       m_isLogin = false;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83f\83X\83g\83\89\83N\83^\r
+////////////////////////////////////////////////////////////////////////////////\r
+CClientConnection::~CClientConnection()\r
+{\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// initialize\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CClientConnection::initialize()\r
+{\r
+       CSocket::initialize();\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// send\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CClientConnection::send(const CommunicationData* in_pCommunicationData)\r
+{\r
+       // \83T\83C\83Y\82Í\8c\88\82ß\91Å\82¿\r
+       if(::send(m_Socket, reinterpret_cast<const char*>(in_pCommunicationData), MAX_COMMUNICATION_DATA_LENGTH, 0) == SOCKET_ERROR){\r
+               return false;\r
+       }\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// receive\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CClientConnection::receive(CommunicationData** out_ppCommunicationData)\r
+{\r
+       if(m_Buffer.empty()){\r
+               return false;\r
+       }\r
+\r
+       *out_ppCommunicationData = reinterpret_cast<CommunicationData*>(m_Buffer.getReadPointer()->m_Buffer);\r
+       m_Buffer.nextReadBuffer();\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// login\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CClientConnection::login(const char* in_pLoginName)\r
+{\r
+       CommunicationData a_SendData;\r
+       a_SendData.m_DataType = 'i';\r
+       strcpy(a_SendData.m_Data.m_LoginData.m_Name, in_pLoginName);\r
+       send(&a_SendData);\r
+\r
+       // \82±\82Ì\83t\83\89\83O\82Í\8eó\90M\83\81\83b\83Z\81[\83W\82ð\8am\82©\82ß\82Ä\82©\82ç\95Ï\8dX\82·\82é\82×\82«\r
+       m_isLogin = true;\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// logout\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CClientConnection::logout()\r
+{\r
+       CommunicationData a_SendData;\r
+       a_SendData.m_DataType = 'o';\r
+       send(&a_SendData);\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \8dÀ\95W\8eæ\93¾\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CClientConnection::requestPosition()\r
+{\r
+       CommunicationData a_SendData;\r
+       a_SendData.m_DataType = 'p';\r
+       send(&a_SendData);\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \88Ú\93®\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CClientConnection::requestMove(char in_Direction)\r
+{\r
+       CommunicationData a_SendData;\r
+       a_SendData.m_DataType = 'a';\r
+       a_SendData.m_Data.m_ActionCommand.m_CommandType = in_Direction;\r
+       send(&a_SendData);\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \89¹\90º\91\97\90M\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CClientConnection::sendVoice(char* in_pVoice, int in_Length, bool in_isEnd)\r
+{\r
+       CommunicationData a_SendData;\r
+\r
+       if(sizeof(a_SendData.m_Data.m_Voice.m_Stream) < in_Length){\r
+               return false;\r
+       }\r
+\r
+       a_SendData.m_DataType = 'v';\r
+       for(int i = 0; i < in_Length; i++){\r
+               a_SendData.m_Data.m_Voice.m_Stream[i] = in_pVoice[i];\r
+       }\r
+       a_SendData.m_Data.m_Voice.m_Length = in_Length;\r
+       a_SendData.m_Data.m_Voice.m_isEnd = in_isEnd;\r
+       send(&a_SendData);\r
+       return true;\r
+}\r
index dfc4bf3..0d9c5d3 100644 (file)
@@ -1,95 +1,95 @@
-#ifndef INC_CClientConnection
-#define INC_CClientConnection
-
-// \83C\83\93\83N\83\8b\81[\83h\82Í\95K\82¸\95K\97v\82È\95¨\82¾\82¯
-// \93à\95\94\82Å\97\98\97p\82·\82é\82¾\82¯\82Ì\95¨\82Í\83\\81[\83X\82É\8bL\8fq
-#include "Environment.h"
-#include "CSocket.h"
-#include "Data.h"
-
-// \8aÖ\90\94\96¼\82Í\83\8d\81[\83\8f\83L\83\83\83\81\83\8b\83P\81[\83X\82Æ\82·\82é
-
-////////////////////////////////////////////////////////////////////////////////
-// CClientConnection
-// \92Ê\90M\97p\83N\83\89\83X
-// internetcity\97p\82Ì\92Ê\90M\97p
-// \83R\83}\83\93\83h\82È\82çTCP\81A\89¹\90º\82È\82çUDP\82ð\8eg\97p\82·\82é
-// \8d\\95\89ð\90Í\82Ì\8b@\94\\82ð\8eÀ\8c»\82·\82é
-// \8f\88\97\9d\82É\82©\82©\82í\82é\93à\97e\82Í\8bL\8fq\82µ\82È\82¢
-////////////////////////////////////////////////////////////////////////////////
-class CClientConnection : public CSocket
-{
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83\81\83\93\83o\95Ï\90\94
-       ////////////////////////////////////////////////////////////////////////////////
-private:
-       // \82 \82Æ\82Å\8fÁ\82·
-       bool m_isLogin;
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83R\83\93\83X\83g\83\89\83N\83^
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       CClientConnection();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83f\83X\83g\83\89\83N\83^
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       ~CClientConnection();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \91\80\8dì\83\81\83\\83b\83h
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       // initialize
-       bool initialize();
-
-       // send\8aÖ\98A
-protected:
-       // send
-       bool send(const CommunicationData* in_pCommunicationData);
-public:
-       // login
-       bool login(const char* in_pLoginName);
-       // logout
-       bool logout();
-       // \8dÀ\95W\8eæ\93¾
-       bool requestPosition();
-       // \88Ú\93®
-       bool requestMove(char in_Direction);
-       // \89¹\90º\91\97\90M
-       bool sendVoice(char* in_pVoice, int in_Length, bool in_isEnd);
-
-       // receive\8aÖ\98A
-public:
-       // receive
-       bool receive(CommunicationData** out_ppCommunicationData);
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \91®\90«\83\81\83\\83b\83h
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83C\83e\83\8c\81[\83V\83\87\83\93
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \8fó\91Ô
-       ////////////////////////////////////////////////////////////////////////////////
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \89\89\8eZ\8eq
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \8f\83\90\88\89¼\91z\8aÖ\90\94\81A\92è\8b`\82Ì\82Ý\81i\94ñ\8eÀ\91\95\92ñ\8b\9f\81j
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \93à\95\94\83N\83\89\83X
-       ////////////////////////////////////////////////////////////////////////////////
-
-
-};
-
-#endif //INC_CClientConnection
+#ifndef INC_CClientConnection\r
+#define INC_CClientConnection\r
+\r
+// \83C\83\93\83N\83\8b\81[\83h\82Í\95K\82¸\95K\97v\82È\95¨\82¾\82¯\r
+// \93à\95\94\82Å\97\98\97p\82·\82é\82¾\82¯\82Ì\95¨\82Í\83\\81[\83X\82É\8bL\8fq\r
+#include "Environment.h"\r
+#include "CSocket.h"\r
+#include "Data.h"\r
+\r
+// \8aÖ\90\94\96¼\82Í\83\8d\81[\83\8f\83L\83\83\83\81\83\8b\83P\81[\83X\82Æ\82·\82é\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// CClientConnection\r
+// \92Ê\90M\97p\83N\83\89\83X\r
+// internetcity\97p\82Ì\92Ê\90M\97p\r
+// \83R\83}\83\93\83h\82È\82çTCP\81A\89¹\90º\82È\82çUDP\82ð\8eg\97p\82·\82é\r
+// \8d\\95\89ð\90Í\82Ì\8b@\94\\82ð\8eÀ\8c»\82·\82é\r
+// \8f\88\97\9d\82É\82©\82©\82í\82é\93à\97e\82Í\8bL\8fq\82µ\82È\82¢\r
+////////////////////////////////////////////////////////////////////////////////\r
+class CClientConnection : public CSocket\r
+{\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83\81\83\93\83o\95Ï\90\94\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+private:\r
+       // \82 \82Æ\82Å\8fÁ\82·\r
+       bool m_isLogin;\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83R\83\93\83X\83g\83\89\83N\83^\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       CClientConnection();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83f\83X\83g\83\89\83N\83^\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       ~CClientConnection();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \91\80\8dì\83\81\83\\83b\83h\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       // initialize\r
+       bool initialize();\r
+\r
+       // send\8aÖ\98A\r
+protected:\r
+       // send\r
+       bool send(const CommunicationData* in_pCommunicationData);\r
+public:\r
+       // login\r
+       bool login(const char* in_pLoginName);\r
+       // logout\r
+       bool logout();\r
+       // \8dÀ\95W\8eæ\93¾\r
+       bool requestPosition();\r
+       // \88Ú\93®\r
+       bool requestMove(char in_Direction);\r
+       // \89¹\90º\91\97\90M\r
+       bool sendVoice(char* in_pVoice, int in_Length, bool in_isEnd);\r
+\r
+       // receive\8aÖ\98A\r
+public:\r
+       // receive\r
+       bool receive(CommunicationData** out_ppCommunicationData);\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \91®\90«\83\81\83\\83b\83h\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83C\83e\83\8c\81[\83V\83\87\83\93\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \8fó\91Ô\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \89\89\8eZ\8eq\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \8f\83\90\88\89¼\91z\8aÖ\90\94\81A\92è\8b`\82Ì\82Ý\81i\94ñ\8eÀ\91\95\92ñ\8b\9f\81j\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \93à\95\94\83N\83\89\83X\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+\r
+\r
+};\r
+\r
+#endif //INC_CClientConnection\r
index c52e639..539317e 100644 (file)
-// \8b\9e
-#include "CInputWave.h"
-
-
-#include <iostream>
-#include <Windows.h>
-#include <MMSystem.h>
-//#include <tchar.h>
-
-////////////////////////////////////////////////////////////////////////////////
-// \83R\83\93\83X\83g\83\89\83N\83^
-////////////////////////////////////////////////////////////////////////////////
-CInputWave::CInputWave()
-{
-       // Wave\83t\83H\81[\83}\83b\83g
-       m_WaveFormat.wFormatTag      = WAVE_FORMAT_PCM;
-       m_WaveFormat.nChannels       = 1;
-       //m_WaveFormat.nSamplesPerSec  = 22050;
-       m_WaveFormat.nSamplesPerSec  = 20800;
-       m_WaveFormat.wBitsPerSample  = 8;
-       m_WaveFormat.nBlockAlign     = m_WaveFormat.wBitsPerSample / 8 * m_WaveFormat.nChannels;
-       m_WaveFormat.nAvgBytesPerSec = m_WaveFormat.nSamplesPerSec * m_WaveFormat.nBlockAlign;
-
-
-       // Wave\83f\83o\83C\83X\83n\83\93\83h\83\8b
-       m_hWaveIn = 0;
-
-       // Wave\83w\83b\83_\81[
-       m_WaveHeaders.allocate(3);
-
-       // Wave\83o\83b\83t\83@
-       int a_RecorMilliSecond = 100;
-       m_WaveBuffers.allocate(10, a_RecorMilliSecond, m_WaveFormat.nAvgBytesPerSec * a_RecorMilliSecond / 1000);
-
-       m_pFinishWaveBuffer = NULL;
-
-       m_pDataFullCallBackFunction = NULL;
-
-       // \83f\83o\83C\83X\82ð\83I\81[\83v\83\93\82µ\82Ä\82¢\82é
-       m_isOpen = false;
-       // \93ü\97Í\92\86
-       m_isInput = false;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \83f\83X\83g\83\89\83N\83^
-////////////////////////////////////////////////////////////////////////////////
-CInputWave::~CInputWave()
-{
-       close();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \93ü\97Í\83f\83o\83C\83X\82Ì\8fó\91Ô\82ð\92m\82ç\82¹\82é\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94
-////////////////////////////////////////////////////////////////////////////////
-void CALLBACK CInputWave::waveInProc(HWAVEIN in_hWaveIn, UINT in_Message, DWORD in_Instance, DWORD in_Param1, DWORD in_Param2)
-{
-       // waveInOpen\8e\9e\82Éin_Instance\82É\83N\83\89\83X\82Ì\83|\83C\83\93\83^\82ð\8ai\94[\82µ\82Ä\82¨\82­
-
-       CInputWave* a_pInputWave = reinterpret_cast<CInputWave*>(in_Instance);
-       a_pInputWave->callbackWave(in_hWaveIn, in_Message, in_Instance, in_Param1, in_Param2);
-}
-
-void CInputWave::callbackWave(HWAVEIN in_hWaveIn, UINT in_Message, DWORD in_Instance, DWORD in_Param1, DWORD in_Param2)
-{
-       // \83\81\83b\83Z\81[\83W\82Ì\8eí\97Þ\82²\82Æ\82Ì\8f\88\97\9d\82ð\8ds\82¤
-       switch(in_Message){
-       // \83f\83o\83C\83X\82ª waveInClose \8aÖ\90\94\82Å\83N\83\8d\81[\83Y\82³\82ê\82½\82Æ\82«\82É\91\97\90M\82³\82ê\82Ü\82·\81B
-       case WIM_CLOSE:
-               std::cout << "WIM_CLOSE" << std::endl;
-               break;
-
-       // \83f\83o\83C\83X\82ª\81AwaveInAddBuffer \8aÖ\90\94\82Å\91\97\90M\82³\82ê\82½\83f\81[\83^\83u\83\8d\83b\83N\82Ì\8f\88\97\9d\82ð\8fI\97¹\82µ\82½\82Æ\82«\82É\91\97\90M\82³\82ê\82Ü\82·\81B
-       case WIM_DATA:
-               std::cout << "WIM_DATA" << std::endl;
-               // \83w\83b\83_\81[\8cã\8f\88\97\9d
-               m_pFinishWaveBuffer = m_WaveHeaders.getReadPointer()->lpData;
-               waveInUnprepareHeader(m_hWaveIn, m_WaveHeaders.getReadPointer(), sizeof(WAVEHDR));
-
-               // \8aO\95\94\8aÖ\90\94\82ð\8cÄ\82Ñ\8fo\82·
-               if(m_pDataFullCallBackFunction != NULL){
-                       (*m_pDataFullCallBackFunction)(m_WaveHeaders.getReadPointer());
-               }
-
-               // \98^\89¹\82ª\8fI\97¹\82µ\82½\82Ì\82ÅWave\83w\83b\83_\81[\82ð\89ð\95ú\82·\82é
-               m_WaveHeaders.nextReadBuffer();
-
-               // \93ü\97Í\83t\83\89\83O\82ª\97§\82Á\82Ä\82¢\82é\8fê\8d\87\81A\8e\9f\82Ì\83o\83b\83t\83@\82ð\83Z\83b\83g\82·\82é
-               if(m_isInput){
-                       addWaveBuffer();
-               }
-               break;
-
-       // \83f\83o\83C\83X\82ª waveInOpen \8aÖ\90\94\82Å\83I\81[\83v\83\93\82³\82ê\82½\82Æ\82«\82É\91\97\90M\82³\82ê\82Ü\82·\81B
-       case WIM_OPEN:
-               std::cout << "WIM_OPEN" << std::endl;
-               break;
-       default:
-               throw "error: WAVE Call Back";
-               break;
-       }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \8f\89\8aú\89»
-////////////////////////////////////////////////////////////////////////////////
-void CInputWave::initialize()
-{
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \83f\83o\83C\83X\82ð\8aJ\82­
-////////////////////////////////////////////////////////////////////////////////
-bool CInputWave::open()
-{
-       // open a wave device handle
-       // \81¦\8aJ\82­\83f\83o\83C\83X\82à\88ø\90\94\82Å\8ew\92è\82Å\82«\82é\82æ\82¤\82É\82·\82é
-       if(waveInOpen(&m_hWaveIn, WAVE_MAPPER, &m_WaveFormat, reinterpret_cast<DWORD>(waveInProc), reinterpret_cast<DWORD>(this), CALLBACK_FUNCTION) != MMSYSERR_NOERROR) {
-               throw "failer open wave device handle";
-               return false;
-       }
-
-       m_isOpen = true;
-
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \83f\83o\83C\83X\82ð\95Â\82\82é
-////////////////////////////////////////////////////////////////////////////////
-bool CInputWave::close()
-{
-       stop();
-
-       if(m_isOpen){
-               m_isOpen = false;
-               // close a wave device handle
-               waveInClose(m_hWaveIn);
-       }
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// add wave buffer in queue
-////////////////////////////////////////////////////////////////////////////////
-bool CInputWave::addWaveBuffer()
-{
-       while(!m_WaveHeaders.full() && !m_WaveBuffers.full()){
-               // \83w\83b\83_\81[\82Æ\8ai\94[\97p\83f\81[\83^\82Ì\83|\83C\83\93\83^\82ð\8eæ\93¾\82·\82é
-               WAVEHDR* a_pWaveHeader = m_WaveHeaders.getWritePointer();
-               StructWaveBuffer* a_pWaveBuffer = m_WaveBuffers.getWritePointer();
-               // \8f\89\8aú\92l\82ð\83Z\83b\83g\82·\82é
-               a_pWaveHeader->lpData         = a_pWaveBuffer->m_pWaveBuffer;
-               a_pWaveHeader->dwBufferLength = a_pWaveBuffer->m_BufferSize;
-               a_pWaveHeader->dwFlags        = 0;
-               // \83|\83C\83\93\83^\82ð\8e\9f\82É\90i\82ß\82é
-               m_WaveHeaders.nextWriteBuffer();
-               m_WaveBuffers.nextWriteBuffer();
-
-               // initialize a wave header
-               // must use this function for initialize, because not open wave header structure
-               switch(waveInPrepareHeader(m_hWaveIn, a_pWaveHeader, sizeof(WAVEHDR))){
-               // \90¬\8c÷
-               case MMSYSERR_NOERROR:
-                       break;
-
-               // \95Ê\82Ì\83X\83\8c\83b\83h\82ª\83n\83\93\83h\83\8b\82ð\8eg\97p\92\86\82Å\82 \82é
-               case MMSYSERR_HANDLEBUSY:
-                       throw "waveInPrepareHeader: \95Ê\82Ì\83X\83\8c\83b\83h\82ª\83n\83\93\83h\83\8b\82ð\8eg\97p\92\86\82Å\82 \82é ";
-                       break;
-               // \83f\83o\83C\83X\83n\83\93\83h\83\8b\82ª\96³\8cø\82Å\82 \82é
-               case MMSYSERR_INVALHANDLE:
-                       throw "waveInPrepareHeader: \83f\83o\83C\83X\83n\83\93\83h\83\8b\82ª\96³\8cø\82Å\82 \82é";
-                       break;
-               // \83f\83o\83C\83X\83h\83\89\83C\83o\82ª\82È\82¢
-               case MMSYSERR_NODRIVER:
-                       throw "waveInPrepareHeader:\83f\83o\83C\83X\83h\83\89\83C\83o\82ª\82È\82¢";
-                       break;
-               // \83\81\83\82\83\8a\82ð\8a\84\82è\93\96\82Ä\82ç\82ê\82È\82¢\81A\82Ü\82½\82Í\83\8d\83b\83N\82Å\82«\82È\82¢
-               case MMSYSERR_NOMEM:
-                       throw "waveInPrepareHeader: \83\81\83\82\83\8a\82ð\8a\84\82è\93\96\82Ä\82ç\82ê\82È\82¢\81A\82Ü\82½\82Í\83\8d\83b\83N\82Å\82«\82È\82¢";
-                       break;
-               }
-
-               // take a buffer for wave
-               switch(waveInAddBuffer(m_hWaveIn, a_pWaveHeader, sizeof(WAVEHDR))){
-               // \90¬\8c÷
-               case MMSYSERR_NOERROR:
-                       break;
-
-               // \95Ê\82Ì\83X\83\8c\83b\83h\82ª\83n\83\93\83h\83\8b\82ð\8eg\97p\92\86\82Å\82 \82é
-               case MMSYSERR_HANDLEBUSY:
-                       throw "waveInAddBuffer: \95Ê\82Ì\83X\83\8c\83b\83h\82ª\83n\83\93\83h\83\8b\82ð\8eg\97p\92\86\82Å\82 \82é";
-                       break;
-
-               // \83f\83o\83C\83X\83n\83\93\83h\83\8b\82ª\96³\8cø\82Å\82 \82é
-               case MMSYSERR_INVALHANDLE:
-                       throw "waveInAddBuffer: \83f\83o\83C\83X\83n\83\93\83h\83\8b\82ª\96³\8cø\82Å\82 \82é";
-                       break;
-
-               // \83f\83o\83C\83X\83h\83\89\83C\83o\82ª\82È\82¢
-               case MMSYSERR_NODRIVER:
-                       throw "waveInAddBuffer: \83f\83o\83C\83X\83h\83\89\83C\83o\82ª\82È\82¢";
-                       break;
-
-               // \83\81\83\82\83\8a\82ð\8a\84\82è\93\96\82Ä\82ç\82ê\82È\82¢\81A\82Ü\82½\82Í\83\8d\83b\83N\82Å\82«\82È\82¢
-               case MMSYSERR_NOMEM:
-                       throw "waveInAddBuffer: \83\81\83\82\83\8a\82ð\8a\84\82è\93\96\82Ä\82ç\82ê\82È\82¢\81A\82Ü\82½\82Í\83\8d\83b\83N\82Å\82«\82È\82¢";
-                       break;
-
-               // \83o\83b\83t\83@\82ª\8f\80\94õ\82³\82ê\82Ä\82¢\82È\82¢
-               case WAVERR_UNPREPARED:
-                       throw "waveInAddBuffer: \83o\83b\83t\83@\82ª\8f\80\94õ\82³\82ê\82Ä\82¢\82È\82¢";
-                       break;
-               }
-       }
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \93ü\97Í\81i\98^\89¹\81j\82ð\8aJ\8en\82·\82é
-////////////////////////////////////////////////////////////////////////////////
-bool CInputWave::start()
-{
-       // \83f\83o\83C\83X\82ð\8aJ\82¢\82Ä\82¢\82È\82¢\82È\82çfalse\82ð\95Ô\82·
-       if(!m_isOpen){
-               return false;
-       }
-
-       // \83o\83b\83t\83@\82É\8ec\82è\82ª\82 \82é\8fê\8d\87\81A\83o\83b\83t\83@\82ð\89Á\82¦\82é
-       if(!m_WaveHeaders.full() && !m_WaveBuffers.full()){
-               addWaveBuffer();
-       }
-       else{
-               return true;
-       }
-
-       // waveInStart\82Í\8eÀ\8ds\92\86\82Ì\8fê\8d\87\81A\89½\93x\8cÄ\82Ñ\8fo\82µ\82Ä\82à\96³\8e\8b\82³\82ê\82é\82Í\82¸\82¾\82ª\81A
-       // \82È\82º\82©\83t\83\8a\81[\83Y\82·\82é\82½\82ß\81A\83o\83b\83t\83@\82Ì\8ec\82è\82ð\8am\94F\82µ\8cÄ\82Ñ\8fo\82·\82©\94»\92è\82·\82é
-
-       switch(waveInStart(m_hWaveIn)){
-       // \90¬\8c÷
-       case MMSYSERR_NOERROR:
-               break;
-
-       // \8ew\92è\82³\82ê\82½\83f\83o\83C\83X\83n\83\93\83h\83\8b\82Í\96³\8cø\82Å\82·\81B
-       case MMSYSERR_INVALHANDLE:
-               throw "\8ew\92è\82³\82ê\82½\83f\83o\83C\83X\83n\83\93\83h\83\8b\82Í\96³\8cø\82Å\82·\81B";
-               return false;
-
-       // \83f\83o\83C\83X\83h\83\89\83C\83o\82ª\91\8dÝ\82µ\82Ü\82¹\82ñ\81B
-       case MMSYSERR_NODRIVER:
-               throw "\83f\83o\83C\83X\83h\83\89\83C\83o\82ª\91\8dÝ\82µ\82Ü\82¹\82ñ\81B";
-               return false;
-
-       // \83\81\83\82\83\8a\82ð\8a\84\82è\93\96\82Ä\82ç\82ê\82È\82¢\82©\81A\82Ü\82½\82Í\83\8d\83b\83N\82Å\82«\82Ü\82¹\82ñ\81B
-       case MMSYSERR_NOMEM:
-               throw "\83\81\83\82\83\8a\82ð\8a\84\82è\93\96\82Ä\82ç\82ê\82È\82¢\82©\81A\82Ü\82½\82Í\83\8d\83b\83N\82Å\82«\82Ü\82¹\82ñ\81B";
-               return false;
-
-       // \82»\82Ì\91¼\82Ì\8f\88\97\9d
-       default:
-               break;
-       }
-       m_isInput = true;
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \93ü\97Í\81i\98^\89¹\81j\82ð\92â\8e~\82·\82é
-////////////////////////////////////////////////////////////////////////////////
-bool CInputWave::stop()
-{
-       // \98^\89¹\92\86\82Å\82È\82¢\82È\82çfalse\82ð\95Ô\82·
-       if(!m_isInput){
-               return false;
-       }
-
-       m_isInput = false;
-       waveInStop(m_hWaveIn);
-
-
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \89¹\90º\83f\81[\83^\82ð\8eæ\93¾\82·\82é
-////////////////////////////////////////////////////////////////////////////////
-StructWaveBuffer* CInputWave::getWaveDataPointer()
-{
-       if(m_pFinishWaveBuffer == NULL){
-               return NULL;
-       }
-
-       if(m_WaveBuffers.getReadPointer()->m_pWaveBuffer != m_pFinishWaveBuffer){
-               StructWaveBuffer* temp = m_WaveBuffers.getReadPointer();
-               m_WaveBuffers.nextReadBuffer();
-               return temp;
-       }
-       return NULL;
-}
+// \8b\9e\r
+#include "CInputWave.h"\r
+\r
+\r
+#include <iostream>\r
+#include <Windows.h>\r
+#include <MMSystem.h>\r
+//#include <tchar.h>\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83R\83\93\83X\83g\83\89\83N\83^\r
+////////////////////////////////////////////////////////////////////////////////\r
+CInputWave::CInputWave()\r
+{\r
+       // Wave\83t\83H\81[\83}\83b\83g\r
+       m_WaveFormat.wFormatTag      = WAVE_FORMAT_PCM;\r
+       m_WaveFormat.nChannels       = 1;\r
+       //m_WaveFormat.nSamplesPerSec  = 22050;\r
+       m_WaveFormat.nSamplesPerSec  = 20800;\r
+       m_WaveFormat.wBitsPerSample  = 8;\r
+       m_WaveFormat.nBlockAlign     = m_WaveFormat.wBitsPerSample / 8 * m_WaveFormat.nChannels;\r
+       m_WaveFormat.nAvgBytesPerSec = m_WaveFormat.nSamplesPerSec * m_WaveFormat.nBlockAlign;\r
+\r
+\r
+       // Wave\83f\83o\83C\83X\83n\83\93\83h\83\8b\r
+       m_hWaveIn = 0;\r
+\r
+       // Wave\83w\83b\83_\81[\r
+       m_WaveHeaders.allocate(3);\r
+\r
+       // Wave\83o\83b\83t\83@\r
+       int a_RecorMilliSecond = 100;\r
+       m_WaveBuffers.allocate(10, a_RecorMilliSecond, m_WaveFormat.nAvgBytesPerSec * a_RecorMilliSecond / 1000);\r
+\r
+       m_pFinishWaveBuffer = NULL;\r
+\r
+       m_pDataFullCallBackFunction = NULL;\r
+\r
+       // \83f\83o\83C\83X\82ð\83I\81[\83v\83\93\82µ\82Ä\82¢\82é\r
+       m_isOpen = false;\r
+       // \93ü\97Í\92\86\r
+       m_isInput = false;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83f\83X\83g\83\89\83N\83^\r
+////////////////////////////////////////////////////////////////////////////////\r
+CInputWave::~CInputWave()\r
+{\r
+       close();\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \93ü\97Í\83f\83o\83C\83X\82Ì\8fó\91Ô\82ð\92m\82ç\82¹\82é\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94\r
+////////////////////////////////////////////////////////////////////////////////\r
+void CALLBACK CInputWave::waveInProc(HWAVEIN in_hWaveIn, UINT in_Message, DWORD in_Instance, DWORD in_Param1, DWORD in_Param2)\r
+{\r
+       // waveInOpen\8e\9e\82Éin_Instance\82É\83N\83\89\83X\82Ì\83|\83C\83\93\83^\82ð\8ai\94[\82µ\82Ä\82¨\82­\r
+\r
+       CInputWave* a_pInputWave = reinterpret_cast<CInputWave*>(in_Instance);\r
+       a_pInputWave->callbackWave(in_hWaveIn, in_Message, in_Instance, in_Param1, in_Param2);\r
+}\r
+\r
+void CInputWave::callbackWave(HWAVEIN in_hWaveIn, UINT in_Message, DWORD in_Instance, DWORD in_Param1, DWORD in_Param2)\r
+{\r
+       // \83\81\83b\83Z\81[\83W\82Ì\8eí\97Þ\82²\82Æ\82Ì\8f\88\97\9d\82ð\8ds\82¤\r
+       switch(in_Message){\r
+       // \83f\83o\83C\83X\82ª waveInClose \8aÖ\90\94\82Å\83N\83\8d\81[\83Y\82³\82ê\82½\82Æ\82«\82É\91\97\90M\82³\82ê\82Ü\82·\81B\r
+       case WIM_CLOSE:\r
+               std::cout << "WIM_CLOSE" << std::endl;\r
+               break;\r
+\r
+       // \83f\83o\83C\83X\82ª\81AwaveInAddBuffer \8aÖ\90\94\82Å\91\97\90M\82³\82ê\82½\83f\81[\83^\83u\83\8d\83b\83N\82Ì\8f\88\97\9d\82ð\8fI\97¹\82µ\82½\82Æ\82«\82É\91\97\90M\82³\82ê\82Ü\82·\81B\r
+       case WIM_DATA:\r
+               std::cout << "WIM_DATA" << std::endl;\r
+               // \83w\83b\83_\81[\8cã\8f\88\97\9d\r
+               m_pFinishWaveBuffer = m_WaveHeaders.getReadPointer()->lpData;\r
+               waveInUnprepareHeader(m_hWaveIn, m_WaveHeaders.getReadPointer(), sizeof(WAVEHDR));\r
+\r
+               // \8aO\95\94\8aÖ\90\94\82ð\8cÄ\82Ñ\8fo\82·\r
+               if(m_pDataFullCallBackFunction != NULL){\r
+                       (*m_pDataFullCallBackFunction)(m_WaveHeaders.getReadPointer());\r
+               }\r
+\r
+               // \98^\89¹\82ª\8fI\97¹\82µ\82½\82Ì\82ÅWave\83w\83b\83_\81[\82ð\89ð\95ú\82·\82é\r
+               m_WaveHeaders.nextReadBuffer();\r
+\r
+               // \93ü\97Í\83t\83\89\83O\82ª\97§\82Á\82Ä\82¢\82é\8fê\8d\87\81A\8e\9f\82Ì\83o\83b\83t\83@\82ð\83Z\83b\83g\82·\82é\r
+               if(m_isInput){\r
+                       addWaveBuffer();\r
+               }\r
+               break;\r
+\r
+       // \83f\83o\83C\83X\82ª waveInOpen \8aÖ\90\94\82Å\83I\81[\83v\83\93\82³\82ê\82½\82Æ\82«\82É\91\97\90M\82³\82ê\82Ü\82·\81B\r
+       case WIM_OPEN:\r
+               std::cout << "WIM_OPEN" << std::endl;\r
+               break;\r
+       default:\r
+               throw "error: WAVE Call Back";\r
+               break;\r
+       }\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \8f\89\8aú\89»\r
+////////////////////////////////////////////////////////////////////////////////\r
+void CInputWave::initialize()\r
+{\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83f\83o\83C\83X\82ð\8aJ\82­\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CInputWave::open()\r
+{\r
+       // open a wave device handle\r
+       // \81¦\8aJ\82­\83f\83o\83C\83X\82à\88ø\90\94\82Å\8ew\92è\82Å\82«\82é\82æ\82¤\82É\82·\82é\r
+       if(waveInOpen(&m_hWaveIn, WAVE_MAPPER, &m_WaveFormat, reinterpret_cast<DWORD>(waveInProc), reinterpret_cast<DWORD>(this), CALLBACK_FUNCTION) != MMSYSERR_NOERROR) {\r
+               throw "failer open wave device handle";\r
+               return false;\r
+       }\r
+\r
+       m_isOpen = true;\r
+\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83f\83o\83C\83X\82ð\95Â\82\82é\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CInputWave::close()\r
+{\r
+       stop();\r
+\r
+       if(m_isOpen){\r
+               m_isOpen = false;\r
+               // close a wave device handle\r
+               waveInClose(m_hWaveIn);\r
+       }\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// add wave buffer in queue\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CInputWave::addWaveBuffer()\r
+{\r
+       while(!m_WaveHeaders.full() && !m_WaveBuffers.full()){\r
+               // \83w\83b\83_\81[\82Æ\8ai\94[\97p\83f\81[\83^\82Ì\83|\83C\83\93\83^\82ð\8eæ\93¾\82·\82é\r
+               WAVEHDR* a_pWaveHeader = m_WaveHeaders.getWritePointer();\r
+               StructWaveBuffer* a_pWaveBuffer = m_WaveBuffers.getWritePointer();\r
+               // \8f\89\8aú\92l\82ð\83Z\83b\83g\82·\82é\r
+               a_pWaveHeader->lpData         = a_pWaveBuffer->m_pWaveBuffer;\r
+               a_pWaveHeader->dwBufferLength = a_pWaveBuffer->m_BufferSize;\r
+               a_pWaveHeader->dwFlags        = 0;\r
+               // \83|\83C\83\93\83^\82ð\8e\9f\82É\90i\82ß\82é\r
+               m_WaveHeaders.nextWriteBuffer();\r
+               m_WaveBuffers.nextWriteBuffer();\r
+\r
+               // initialize a wave header\r
+               // must use this function for initialize, because not open wave header structure\r
+               switch(waveInPrepareHeader(m_hWaveIn, a_pWaveHeader, sizeof(WAVEHDR))){\r
+               // \90¬\8c÷\r
+               case MMSYSERR_NOERROR:\r
+                       break;\r
+\r
+               // \95Ê\82Ì\83X\83\8c\83b\83h\82ª\83n\83\93\83h\83\8b\82ð\8eg\97p\92\86\82Å\82 \82é\r
+               case MMSYSERR_HANDLEBUSY:\r
+                       throw "waveInPrepareHeader: \95Ê\82Ì\83X\83\8c\83b\83h\82ª\83n\83\93\83h\83\8b\82ð\8eg\97p\92\86\82Å\82 \82é ";\r
+                       break;\r
+               // \83f\83o\83C\83X\83n\83\93\83h\83\8b\82ª\96³\8cø\82Å\82 \82é\r
+               case MMSYSERR_INVALHANDLE:\r
+                       throw "waveInPrepareHeader: \83f\83o\83C\83X\83n\83\93\83h\83\8b\82ª\96³\8cø\82Å\82 \82é";\r
+                       break;\r
+               // \83f\83o\83C\83X\83h\83\89\83C\83o\82ª\82È\82¢\r
+               case MMSYSERR_NODRIVER:\r
+                       throw "waveInPrepareHeader:\83f\83o\83C\83X\83h\83\89\83C\83o\82ª\82È\82¢";\r
+                       break;\r
+               // \83\81\83\82\83\8a\82ð\8a\84\82è\93\96\82Ä\82ç\82ê\82È\82¢\81A\82Ü\82½\82Í\83\8d\83b\83N\82Å\82«\82È\82¢\r
+               case MMSYSERR_NOMEM:\r
+                       throw "waveInPrepareHeader: \83\81\83\82\83\8a\82ð\8a\84\82è\93\96\82Ä\82ç\82ê\82È\82¢\81A\82Ü\82½\82Í\83\8d\83b\83N\82Å\82«\82È\82¢";\r
+                       break;\r
+               }\r
+\r
+               // take a buffer for wave\r
+               switch(waveInAddBuffer(m_hWaveIn, a_pWaveHeader, sizeof(WAVEHDR))){\r
+               // \90¬\8c÷\r
+               case MMSYSERR_NOERROR:\r
+                       break;\r
+\r
+               // \95Ê\82Ì\83X\83\8c\83b\83h\82ª\83n\83\93\83h\83\8b\82ð\8eg\97p\92\86\82Å\82 \82é\r
+               case MMSYSERR_HANDLEBUSY:\r
+                       throw "waveInAddBuffer: \95Ê\82Ì\83X\83\8c\83b\83h\82ª\83n\83\93\83h\83\8b\82ð\8eg\97p\92\86\82Å\82 \82é";\r
+                       break;\r
+\r
+               // \83f\83o\83C\83X\83n\83\93\83h\83\8b\82ª\96³\8cø\82Å\82 \82é\r
+               case MMSYSERR_INVALHANDLE:\r
+                       throw "waveInAddBuffer: \83f\83o\83C\83X\83n\83\93\83h\83\8b\82ª\96³\8cø\82Å\82 \82é";\r
+                       break;\r
+\r
+               // \83f\83o\83C\83X\83h\83\89\83C\83o\82ª\82È\82¢\r
+               case MMSYSERR_NODRIVER:\r
+                       throw "waveInAddBuffer: \83f\83o\83C\83X\83h\83\89\83C\83o\82ª\82È\82¢";\r
+                       break;\r
+\r
+               // \83\81\83\82\83\8a\82ð\8a\84\82è\93\96\82Ä\82ç\82ê\82È\82¢\81A\82Ü\82½\82Í\83\8d\83b\83N\82Å\82«\82È\82¢\r
+               case MMSYSERR_NOMEM:\r
+                       throw "waveInAddBuffer: \83\81\83\82\83\8a\82ð\8a\84\82è\93\96\82Ä\82ç\82ê\82È\82¢\81A\82Ü\82½\82Í\83\8d\83b\83N\82Å\82«\82È\82¢";\r
+                       break;\r
+\r
+               // \83o\83b\83t\83@\82ª\8f\80\94õ\82³\82ê\82Ä\82¢\82È\82¢\r
+               case WAVERR_UNPREPARED:\r
+                       throw "waveInAddBuffer: \83o\83b\83t\83@\82ª\8f\80\94õ\82³\82ê\82Ä\82¢\82È\82¢";\r
+                       break;\r
+               }\r
+       }\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \93ü\97Í\81i\98^\89¹\81j\82ð\8aJ\8en\82·\82é\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CInputWave::start()\r
+{\r
+       // \83f\83o\83C\83X\82ð\8aJ\82¢\82Ä\82¢\82È\82¢\82È\82çfalse\82ð\95Ô\82·\r
+       if(!m_isOpen){\r
+               return false;\r
+       }\r
+\r
+       // \83o\83b\83t\83@\82É\8ec\82è\82ª\82 \82é\8fê\8d\87\81A\83o\83b\83t\83@\82ð\89Á\82¦\82é\r
+       if(!m_WaveHeaders.full() && !m_WaveBuffers.full()){\r
+               addWaveBuffer();\r
+       }\r
+       else{\r
+               return true;\r
+       }\r
+\r
+       // waveInStart\82Í\8eÀ\8ds\92\86\82Ì\8fê\8d\87\81A\89½\93x\8cÄ\82Ñ\8fo\82µ\82Ä\82à\96³\8e\8b\82³\82ê\82é\82Í\82¸\82¾\82ª\81A\r
+       // \82È\82º\82©\83t\83\8a\81[\83Y\82·\82é\82½\82ß\81A\83o\83b\83t\83@\82Ì\8ec\82è\82ð\8am\94F\82µ\8cÄ\82Ñ\8fo\82·\82©\94»\92è\82·\82é\r
+\r
+       switch(waveInStart(m_hWaveIn)){\r
+       // \90¬\8c÷\r
+       case MMSYSERR_NOERROR:\r
+               break;\r
+\r
+       // \8ew\92è\82³\82ê\82½\83f\83o\83C\83X\83n\83\93\83h\83\8b\82Í\96³\8cø\82Å\82·\81B\r
+       case MMSYSERR_INVALHANDLE:\r
+               throw "\8ew\92è\82³\82ê\82½\83f\83o\83C\83X\83n\83\93\83h\83\8b\82Í\96³\8cø\82Å\82·\81B";\r
+               return false;\r
+\r
+       // \83f\83o\83C\83X\83h\83\89\83C\83o\82ª\91\8dÝ\82µ\82Ü\82¹\82ñ\81B\r
+       case MMSYSERR_NODRIVER:\r
+               throw "\83f\83o\83C\83X\83h\83\89\83C\83o\82ª\91\8dÝ\82µ\82Ü\82¹\82ñ\81B";\r
+               return false;\r
+\r
+       // \83\81\83\82\83\8a\82ð\8a\84\82è\93\96\82Ä\82ç\82ê\82È\82¢\82©\81A\82Ü\82½\82Í\83\8d\83b\83N\82Å\82«\82Ü\82¹\82ñ\81B\r
+       case MMSYSERR_NOMEM:\r
+               throw "\83\81\83\82\83\8a\82ð\8a\84\82è\93\96\82Ä\82ç\82ê\82È\82¢\82©\81A\82Ü\82½\82Í\83\8d\83b\83N\82Å\82«\82Ü\82¹\82ñ\81B";\r
+               return false;\r
+\r
+       // \82»\82Ì\91¼\82Ì\8f\88\97\9d\r
+       default:\r
+               break;\r
+       }\r
+       m_isInput = true;\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \93ü\97Í\81i\98^\89¹\81j\82ð\92â\8e~\82·\82é\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CInputWave::stop()\r
+{\r
+       // \98^\89¹\92\86\82Å\82È\82¢\82È\82çfalse\82ð\95Ô\82·\r
+       if(!m_isInput){\r
+               return false;\r
+       }\r
+\r
+       m_isInput = false;\r
+       waveInStop(m_hWaveIn);\r
+\r
+\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \89¹\90º\83f\81[\83^\82ð\8eæ\93¾\82·\82é\r
+////////////////////////////////////////////////////////////////////////////////\r
+StructWaveBuffer* CInputWave::getWaveDataPointer()\r
+{\r
+       if(m_pFinishWaveBuffer == NULL){\r
+               return NULL;\r
+       }\r
+\r
+       if(m_WaveBuffers.getReadPointer()->m_pWaveBuffer != m_pFinishWaveBuffer){\r
+               StructWaveBuffer* temp = m_WaveBuffers.getReadPointer();\r
+               m_WaveBuffers.nextReadBuffer();\r
+               return temp;\r
+       }\r
+       return NULL;\r
+}\r
index bb97f0f..bd8eeb2 100644 (file)
-// \8b\9e
-#ifndef INC_CInputWave
-#define INC_CInputWave
-
-// \83C\83\93\83N\83\8b\81[\83h\82Í\95K\82¸\95K\97v\82È\95¨\82¾\82¯
-// \93à\95\94\82Å\97\98\97p\82·\82é\82¾\82¯\82Ì\95¨\82Í\83\\81[\83X\82É\8bL\8fq
-
-// \8aÖ\90\94\96¼\82Í\83\8d\81[\83\8f\83L\83\83\83\81\83\8b\83P\81[\83X\82Æ\82·\82é
-
-
-#include "CWaveData.h"
-#include "CRingBuffer.h"
-
-// \89¹\90º\93ü\97Í\8a®\97¹\8cã\82É\8cÄ\82Ñ\8fo\82·\8aÖ\90\94\82Ö\82Ì\83|\83C\83\93\83^
-// \8d¡\8cã\82à\82±\82Ì\8b@\94\\82ð\8ec\82·\8fê\8d\87\81A\8aÖ\90\94\83I\83u\83W\83F\83N\83g\82É\92u\82«\8a·\82¦\82é
-typedef void (*DataFullCallBack)(WAVEHDR*);
-
-////////////////////////////////////////////////////////////////////////////////
-// CInputWave
-////////////////////////////////////////////////////////////////////////////////
-class CInputWave
-{
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83\81\83\93\83o\95Ï\90\94
-       ////////////////////////////////////////////////////////////////////////////////
-private:
-       // wave format
-       WAVEFORMATEX m_WaveFormat;
-       // Wave\83f\83o\83C\83X\83n\83\93\83h\83\8b
-       HWAVEIN m_hWaveIn;
-       // Wave\83w\83b\83_\81[
-       typedef CRingBuffer<WAVEHDR> WaveHeaderTable;
-       WaveHeaderTable m_WaveHeaders;
-       // Wave\83o\83b\83t\83@
-       //typedef CRingBuffer<StructWaveBuffer> WaveBufferTable;
-       CWaveData m_WaveBuffers;
-       char* m_pFinishWaveBuffer;
-
-       // \8aÖ\90\94\83|\83C\83\93\83^
-       DataFullCallBack m_pDataFullCallBackFunction;
-
-       // \83f\83o\83C\83X\82ð\83I\81[\83v\83\93\82µ\82Ä\82¢\82é
-       bool m_isOpen;
-       // \98^\89¹\92\86
-       bool m_isInput;
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83R\83\93\83X\83g\83\89\83N\83^
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       CInputWave();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83f\83X\83g\83\89\83N\83^
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       virtual ~CInputWave();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94
-       ////////////////////////////////////////////////////////////////////////////////
-       // \93ü\97Í\83f\83o\83C\83X\82Ì\8fó\91Ô\82ð\92m\82ç\82¹\82é\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94
-       static void CALLBACK waveInProc(HWAVEIN in_hWaveIn, UINT in_Message, DWORD in_Instance, DWORD in_Param1, DWORD in_Param2);
-       void callbackWave(HWAVEIN in_hWaveIn, UINT in_Message, DWORD in_Instance, DWORD in_Param1, DWORD in_Param2);
-
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \91\80\8dì\83\81\83\\83b\83h
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       // \8f\89\8aú\89»
-       void initialize();
-       // \83f\83o\83C\83X\82ð\8aJ\82­
-       bool open();
-       // \83f\83o\83C\83X\82ð\95Â\82\82é
-       bool close();
-protected:
-       // add wave buffer in queue
-       bool addWaveBuffer();
-public:
-       // \93ü\97Í\81i\98^\89¹\81j\82ð\8aJ\8en\82·\82é
-       bool start();
-       // \93ü\97Í\81i\98^\89¹\81j\82ð\92â\8e~\82·\82é
-       bool stop();
-       // \89¹\90º\83f\81[\83^\82ð\8eæ\93¾\82·\82é
-       StructWaveBuffer* getWaveDataPointer();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \91®\90«\83\81\83\\83b\83h
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       void setDataFullCallBack(DataFullCallBack in_pDataFullCallBack)
-       {
-               m_pDataFullCallBackFunction = in_pDataFullCallBack;
-       }
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83C\83e\83\8c\81[\83V\83\87\83\93
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \8fó\91Ô
-       ////////////////////////////////////////////////////////////////////////////////
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \89\89\8eZ\8eq
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \8f\83\90\88\89¼\91z\8aÖ\90\94\81A\92è\8b`\82Ì\82Ý\81i\94ñ\8eÀ\91\95\92ñ\8b\9f\81j
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \93à\95\94\83N\83\89\83X
-       ////////////////////////////////////////////////////////////////////////////////
-
-
-};
-
-#endif //INC_CInputWave
+// \8b\9e\r
+#ifndef INC_CInputWave\r
+#define INC_CInputWave\r
+\r
+// \83C\83\93\83N\83\8b\81[\83h\82Í\95K\82¸\95K\97v\82È\95¨\82¾\82¯\r
+// \93à\95\94\82Å\97\98\97p\82·\82é\82¾\82¯\82Ì\95¨\82Í\83\\81[\83X\82É\8bL\8fq\r
+\r
+// \8aÖ\90\94\96¼\82Í\83\8d\81[\83\8f\83L\83\83\83\81\83\8b\83P\81[\83X\82Æ\82·\82é\r
+\r
+\r
+#include "CWaveData.h"\r
+#include "CRingBuffer.h"\r
+\r
+// \89¹\90º\93ü\97Í\8a®\97¹\8cã\82É\8cÄ\82Ñ\8fo\82·\8aÖ\90\94\82Ö\82Ì\83|\83C\83\93\83^\r
+// \8d¡\8cã\82à\82±\82Ì\8b@\94\\82ð\8ec\82·\8fê\8d\87\81A\8aÖ\90\94\83I\83u\83W\83F\83N\83g\82É\92u\82«\8a·\82¦\82é\r
+typedef void (*DataFullCallBack)(WAVEHDR*);\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// CInputWave\r
+////////////////////////////////////////////////////////////////////////////////\r
+class CInputWave\r
+{\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83\81\83\93\83o\95Ï\90\94\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+private:\r
+       // wave format\r
+       WAVEFORMATEX m_WaveFormat;\r
+       // Wave\83f\83o\83C\83X\83n\83\93\83h\83\8b\r
+       HWAVEIN m_hWaveIn;\r
+       // Wave\83w\83b\83_\81[\r
+       typedef CRingBuffer<WAVEHDR> WaveHeaderTable;\r
+       WaveHeaderTable m_WaveHeaders;\r
+       // Wave\83o\83b\83t\83@\r
+       //typedef CRingBuffer<StructWaveBuffer> WaveBufferTable;\r
+       CWaveData m_WaveBuffers;\r
+       char* m_pFinishWaveBuffer;\r
+\r
+       // \8aÖ\90\94\83|\83C\83\93\83^\r
+       DataFullCallBack m_pDataFullCallBackFunction;\r
+\r
+       // \83f\83o\83C\83X\82ð\83I\81[\83v\83\93\82µ\82Ä\82¢\82é\r
+       bool m_isOpen;\r
+       // \98^\89¹\92\86\r
+       bool m_isInput;\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83R\83\93\83X\83g\83\89\83N\83^\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       CInputWave();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83f\83X\83g\83\89\83N\83^\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       virtual ~CInputWave();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \93ü\97Í\83f\83o\83C\83X\82Ì\8fó\91Ô\82ð\92m\82ç\82¹\82é\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94\r
+       static void CALLBACK waveInProc(HWAVEIN in_hWaveIn, UINT in_Message, DWORD in_Instance, DWORD in_Param1, DWORD in_Param2);\r
+       void callbackWave(HWAVEIN in_hWaveIn, UINT in_Message, DWORD in_Instance, DWORD in_Param1, DWORD in_Param2);\r
+\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \91\80\8dì\83\81\83\\83b\83h\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       // \8f\89\8aú\89»\r
+       void initialize();\r
+       // \83f\83o\83C\83X\82ð\8aJ\82­\r
+       bool open();\r
+       // \83f\83o\83C\83X\82ð\95Â\82\82é\r
+       bool close();\r
+protected:\r
+       // add wave buffer in queue\r
+       bool addWaveBuffer();\r
+public:\r
+       // \93ü\97Í\81i\98^\89¹\81j\82ð\8aJ\8en\82·\82é\r
+       bool start();\r
+       // \93ü\97Í\81i\98^\89¹\81j\82ð\92â\8e~\82·\82é\r
+       bool stop();\r
+       // \89¹\90º\83f\81[\83^\82ð\8eæ\93¾\82·\82é\r
+       StructWaveBuffer* getWaveDataPointer();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \91®\90«\83\81\83\\83b\83h\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       void setDataFullCallBack(DataFullCallBack in_pDataFullCallBack)\r
+       {\r
+               m_pDataFullCallBackFunction = in_pDataFullCallBack;\r
+       }\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83C\83e\83\8c\81[\83V\83\87\83\93\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \8fó\91Ô\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \89\89\8eZ\8eq\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \8f\83\90\88\89¼\91z\8aÖ\90\94\81A\92è\8b`\82Ì\82Ý\81i\94ñ\8eÀ\91\95\92ñ\8b\9f\81j\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \93à\95\94\83N\83\89\83X\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+\r
+\r
+};\r
+\r
+#endif //INC_CInputWave\r
index fe544c6..7ab3e8f 100644 (file)
-// \8b\9e
-#include "COutputWave.h"
-
-
-#include <iostream>
-#include <Windows.h>
-#include <MMSystem.h>
-//#include <tchar.h>
-
-
-////////////////////////////////////////////////////////////////////////////////
-// \83R\83\93\83X\83g\83\89\83N\83^
-////////////////////////////////////////////////////////////////////////////////
-COutputWave::COutputWave()
-{
-       // Wave\83t\83H\81[\83}\83b\83g
-       m_WaveFormat.wFormatTag      = WAVE_FORMAT_PCM;
-       m_WaveFormat.nChannels       = 1;
-       //m_WaveFormat.nSamplesPerSec  = 22050;
-       m_WaveFormat.nSamplesPerSec  = 20800;
-       m_WaveFormat.wBitsPerSample  = 8;
-       m_WaveFormat.nBlockAlign     = m_WaveFormat.wBitsPerSample / 8 * m_WaveFormat.nChannels;
-       m_WaveFormat.nAvgBytesPerSec = m_WaveFormat.nSamplesPerSec * m_WaveFormat.nBlockAlign;
-
-
-       // Wave\83f\83o\83C\83X\83n\83\93\83h\83\8b
-       m_hWaveOut = 0;
-
-       // Wave\83w\83b\83_\81[
-       m_WaveHeaders.allocate(3);
-
-       // Wave\83o\83b\83t\83@
-       int a_RecorMilliSecond = 100;
-       m_WaveBuffers.allocate(10, a_RecorMilliSecond, m_WaveFormat.nAvgBytesPerSec * a_RecorMilliSecond / 1000);
-
-       //m_pFinishWaveBuffer = NULL;
-
-       // \83f\83o\83C\83X\82ð\83I\81[\83v\83\93\82µ\82Ä\82¢\82é
-       m_isOpen = false;
-       // \8dÄ\90\92\86
-       m_isOutput = false;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \83f\83X\83g\83\89\83N\83^
-////////////////////////////////////////////////////////////////////////////////
-COutputWave::~COutputWave()
-{
-       close();
-}
-
-
-////////////////////////////////////////////////////////////////////////////////
-// \8fo\97Í\83f\83o\83C\83X\82Ì\8fó\91Ô\82ð\92m\82ç\82¹\82é\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94
-////////////////////////////////////////////////////////////////////////////////
-void CALLBACK COutputWave::waveOutProc(HWAVEOUT in_hWaveOut, UINT in_Message, DWORD in_Instance, DWORD in_Param1, DWORD in_Param2)
-{
-       // waveInOpen\8e\9e\82Éin_Instance\82É\83N\83\89\83X\82Ì\83|\83C\83\93\83^\82ð\8ai\94[\82µ\82Ä\82¨\82­
-
-       COutputWave* a_pOutputWave = reinterpret_cast<COutputWave*>(in_Instance);
-       a_pOutputWave->callbackWave(in_hWaveOut, in_Message, in_Instance, in_Param1, in_Param2);
-}
-
-void COutputWave::callbackWave(HWAVEOUT in_hWaveOut, UINT in_Message, DWORD in_Instance, DWORD in_Param1, DWORD in_Param2)
-{
-       // \83\81\83b\83Z\81[\83W\82Ì\8eí\97Þ\82²\82Æ\82Ì\8f\88\97\9d\82ð\8ds\82¤
-       switch(in_Message){
-       // \83f\83o\83C\83X\82ª waveOutClose \8aÖ\90\94\82Å\83N\83\8d\81[\83Y\82³\82ê\82½\82Æ\82«\82É\91\97\90M\82³\82ê\82Ü\82·\81B
-       case WOM_CLOSE:
-               std::cout << "WOM_CLOSE" << std::endl;
-               break;
-
-       // \83f\83o\83C\83X\83h\83\89\83C\83o\82ª\81AwaveOutWrite \8aÖ\90\94\82Å\91\97\90M\82³\82ê\82½\83f\81[\83^\83u\83\8d\83b\83N\82Ì\8f\88\97\9d\82ð\8fI\97¹\82µ\82½\82Æ\82«\82É\91\97\90M\82³\82ê\82Ü\82·\81B
-       case WOM_DONE:
-               std::cout << "WOM_DATA" << std::endl;
-               // \83w\83b\83_\81[\8cã\8f\88\97\9d
-               //m_pFinishWaveBuffer = m_WaveHeaders.getReadPointer()->lpData;
-               waveOutUnprepareHeader(m_hWaveOut, m_WaveHeaders.getReadPointer(), sizeof(WAVEHDR));
-
-               // \8dÄ\90\82ª\8fI\97¹\82µ\82½\82Ì\82ÅWave\83w\83b\83_\81[\82ð\89ð\95ú\82·\82é
-               m_WaveHeaders.nextReadBuffer();
-
-               if(m_isOutput){
-                       addWaveBuffer();
-               }
-               break;
-
-       // \83f\83o\83C\83X\82ª waveOutOpen \8aÖ\90\94\82Å\83I\81[\83v\83\93\82³\82ê\82½\82Æ\82«\82É\91\97\90M\82³\82ê\82Ü\82·\81B
-       case WOM_OPEN:
-               std::cout << "WOM_OPEN" << std::endl;
-               break;
-       default:
-               throw "error: WAVE Call Back";
-               break;
-       }
-}
-
-
-////////////////////////////////////////////////////////////////////////////////
-// \8f\89\8aú\89»
-////////////////////////////////////////////////////////////////////////////////
-void COutputWave::initialize()
-{
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \83f\83o\83C\83X\82ð\8aJ\82­
-////////////////////////////////////////////////////////////////////////////////
-bool COutputWave::open()
-{
-       // \83f\83o\83C\83X\82ð\8aJ\82­
-       // \8aJ\82­\83f\83o\83C\83X\82à\88ø\90\94\82Å\8ew\92è\82Å\82«\82é\82æ\82¤\82É\82·\82é
-       if(waveOutOpen(&m_hWaveOut, WAVE_MAPPER, &m_WaveFormat, reinterpret_cast<DWORD>(waveOutProc), reinterpret_cast<DWORD>(this), CALLBACK_FUNCTION) != MMSYSERR_NOERROR) {
-               //MessageBox(NULL, TEXT("WAVE\83f\83o\83C\83X\82Ì\83I\81[\83v\83\93\82É\8e¸\94s\82µ\82Ü\82µ\82½\81B"), NULL, MB_ICONWARNING);
-               throw "WAVE\83f\83o\83C\83X\82Ì\83I\81[\83v\83\93\82É\8e¸\94s\82µ\82Ü\82µ\82½\81B";
-               return false;
-       }
-
-       m_isOpen = true;
-
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \83f\83o\83C\83X\82ð\95Â\82\82é
-////////////////////////////////////////////////////////////////////////////////
-bool COutputWave::close()
-{
-       if(m_isOpen){
-               m_isOpen = false;
-               // \83f\83o\83C\83X\83N\83\8d\81[\83Y\8aÖ\90\94
-               waveOutClose(m_hWaveOut);
-       }
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// add wave buffer in queue
-////////////////////////////////////////////////////////////////////////////////
-bool COutputWave::addWaveBuffer()
-{
-       while(!m_WaveHeaders.full() && !m_WaveBuffers.empty()){
-               // \83w\83b\83_\81[\82Æ\8ai\94[\97p\83f\81[\83^\82Ì\83|\83C\83\93\83^\82ð\8eæ\93¾\82·\82é
-               WAVEHDR* a_pWaveHeader = m_WaveHeaders.getWritePointer();
-               StructWaveBuffer* a_pWaveBuffer = m_WaveBuffers.getReadPointer();
-               // \8f\89\8aú\92l\82ð\83Z\83b\83g\82·\82é
-               a_pWaveHeader->lpData         = a_pWaveBuffer->m_pWaveBuffer;
-               a_pWaveHeader->dwBufferLength = a_pWaveBuffer->m_BufferSize;
-               a_pWaveHeader->dwFlags        = 0;
-               // \83|\83C\83\93\83^\82ð\8e\9f\82É\90i\82ß\82é
-               m_WaveHeaders.nextWriteBuffer();
-               m_WaveBuffers.nextReadBuffer();
-
-               if(a_pWaveHeader->lpData == NULL){
-                       return false;
-               }
-
-               // \83w\83b\83_\81[\82ð\8f\80\94õ\82·\82é
-               waveOutPrepareHeader(m_hWaveOut, a_pWaveHeader, sizeof(WAVEHDR));
-
-               // \8fo\97Í\81i\8dÄ\90\81j\82ð\8aJ\8en\82·\82é
-               waveOutWrite(m_hWaveOut, a_pWaveHeader, sizeof(WAVEHDR));
-       }
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \8fo\97Í\81i\8dÄ\90\81j\82ð\8aJ\8en\82·\82é
-////////////////////////////////////////////////////////////////////////////////
-bool COutputWave::start()
-{
-       // \83f\83o\83C\83X\82ð\8aJ\82¢\82Ä\82¢\82È\82¢\82È\82çfalse\82ð\95Ô\82·
-       if(!m_isOpen){
-               return false;
-       }
-
-       addWaveBuffer();
-
-       m_isOutput = true;
-
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \8fo\97Í\81i\8dÄ\90\81j\82ð\92â\8e~\82·\82é
-////////////////////////////////////////////////////////////////////////////////
-bool COutputWave::stop()
-{
-       // \8dÄ\90\92\86\82Å\82È\82¢\8fê\8d\87false\82ð\95Ô\82·
-       if(!m_isOutput){
-               return false;
-       }
-
-       waveOutReset(m_hWaveOut);
-       m_isOutput = false;
-
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \89¹\90º\83f\81[\83^\82ð\83Z\83b\83g\82·\82é
-////////////////////////////////////////////////////////////////////////////////
-bool COutputWave::setWaveDataPointer(const StructWaveBuffer* in_pWaveBuffer)
-{
-       if(in_pWaveBuffer == NULL){
-               return false;
-       }
-
-       StructWaveBuffer* temp = m_WaveBuffers.getWritePointer();
-
-       if(temp == NULL){
-               return false;
-       }
-
-       temp->m_BufferSize = in_pWaveBuffer->m_BufferSize;
-       temp->m_RecorMilliSecond = in_pWaveBuffer->m_RecorMilliSecond;
-       for(unsigned int i = 0; i < in_pWaveBuffer->m_BufferSize; i++){
-               temp->m_pWaveBuffer[i] = in_pWaveBuffer->m_pWaveBuffer[i];
-       }
-
-       m_WaveBuffers.nextWriteBuffer();
-       return true;
-}
+// \8b\9e\r
+#include "COutputWave.h"\r
+\r
+\r
+#include <iostream>\r
+#include <Windows.h>\r
+#include <MMSystem.h>\r
+//#include <tchar.h>\r
+\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83R\83\93\83X\83g\83\89\83N\83^\r
+////////////////////////////////////////////////////////////////////////////////\r
+COutputWave::COutputWave()\r
+{\r
+       // Wave\83t\83H\81[\83}\83b\83g\r
+       m_WaveFormat.wFormatTag      = WAVE_FORMAT_PCM;\r
+       m_WaveFormat.nChannels       = 1;\r
+       //m_WaveFormat.nSamplesPerSec  = 22050;\r
+       m_WaveFormat.nSamplesPerSec  = 20800;\r
+       m_WaveFormat.wBitsPerSample  = 8;\r
+       m_WaveFormat.nBlockAlign     = m_WaveFormat.wBitsPerSample / 8 * m_WaveFormat.nChannels;\r
+       m_WaveFormat.nAvgBytesPerSec = m_WaveFormat.nSamplesPerSec * m_WaveFormat.nBlockAlign;\r
+\r
+\r
+       // Wave\83f\83o\83C\83X\83n\83\93\83h\83\8b\r
+       m_hWaveOut = 0;\r
+\r
+       // Wave\83w\83b\83_\81[\r
+       m_WaveHeaders.allocate(3);\r
+\r
+       // Wave\83o\83b\83t\83@\r
+       int a_RecorMilliSecond = 100;\r
+       m_WaveBuffers.allocate(10, a_RecorMilliSecond, m_WaveFormat.nAvgBytesPerSec * a_RecorMilliSecond / 1000);\r
+\r
+       //m_pFinishWaveBuffer = NULL;\r
+\r
+       // \83f\83o\83C\83X\82ð\83I\81[\83v\83\93\82µ\82Ä\82¢\82é\r
+       m_isOpen = false;\r
+       // \8dÄ\90\92\86\r
+       m_isOutput = false;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83f\83X\83g\83\89\83N\83^\r
+////////////////////////////////////////////////////////////////////////////////\r
+COutputWave::~COutputWave()\r
+{\r
+       close();\r
+}\r
+\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \8fo\97Í\83f\83o\83C\83X\82Ì\8fó\91Ô\82ð\92m\82ç\82¹\82é\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94\r
+////////////////////////////////////////////////////////////////////////////////\r
+void CALLBACK COutputWave::waveOutProc(HWAVEOUT in_hWaveOut, UINT in_Message, DWORD in_Instance, DWORD in_Param1, DWORD in_Param2)\r
+{\r
+       // waveInOpen\8e\9e\82Éin_Instance\82É\83N\83\89\83X\82Ì\83|\83C\83\93\83^\82ð\8ai\94[\82µ\82Ä\82¨\82­\r
+\r
+       COutputWave* a_pOutputWave = reinterpret_cast<COutputWave*>(in_Instance);\r
+       a_pOutputWave->callbackWave(in_hWaveOut, in_Message, in_Instance, in_Param1, in_Param2);\r
+}\r
+\r
+void COutputWave::callbackWave(HWAVEOUT in_hWaveOut, UINT in_Message, DWORD in_Instance, DWORD in_Param1, DWORD in_Param2)\r
+{\r
+       // \83\81\83b\83Z\81[\83W\82Ì\8eí\97Þ\82²\82Æ\82Ì\8f\88\97\9d\82ð\8ds\82¤\r
+       switch(in_Message){\r
+       // \83f\83o\83C\83X\82ª waveOutClose \8aÖ\90\94\82Å\83N\83\8d\81[\83Y\82³\82ê\82½\82Æ\82«\82É\91\97\90M\82³\82ê\82Ü\82·\81B\r
+       case WOM_CLOSE:\r
+               std::cout << "WOM_CLOSE" << std::endl;\r
+               break;\r
+\r
+       // \83f\83o\83C\83X\83h\83\89\83C\83o\82ª\81AwaveOutWrite \8aÖ\90\94\82Å\91\97\90M\82³\82ê\82½\83f\81[\83^\83u\83\8d\83b\83N\82Ì\8f\88\97\9d\82ð\8fI\97¹\82µ\82½\82Æ\82«\82É\91\97\90M\82³\82ê\82Ü\82·\81B\r
+       case WOM_DONE:\r
+               std::cout << "WOM_DATA" << std::endl;\r
+               // \83w\83b\83_\81[\8cã\8f\88\97\9d\r
+               //m_pFinishWaveBuffer = m_WaveHeaders.getReadPointer()->lpData;\r
+               waveOutUnprepareHeader(m_hWaveOut, m_WaveHeaders.getReadPointer(), sizeof(WAVEHDR));\r
+\r
+               // \8dÄ\90\82ª\8fI\97¹\82µ\82½\82Ì\82ÅWave\83w\83b\83_\81[\82ð\89ð\95ú\82·\82é\r
+               m_WaveHeaders.nextReadBuffer();\r
+\r
+               if(m_isOutput){\r
+                       addWaveBuffer();\r
+               }\r
+               break;\r
+\r
+       // \83f\83o\83C\83X\82ª waveOutOpen \8aÖ\90\94\82Å\83I\81[\83v\83\93\82³\82ê\82½\82Æ\82«\82É\91\97\90M\82³\82ê\82Ü\82·\81B\r
+       case WOM_OPEN:\r
+               std::cout << "WOM_OPEN" << std::endl;\r
+               break;\r
+       default:\r
+               throw "error: WAVE Call Back";\r
+               break;\r
+       }\r
+}\r
+\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \8f\89\8aú\89»\r
+////////////////////////////////////////////////////////////////////////////////\r
+void COutputWave::initialize()\r
+{\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83f\83o\83C\83X\82ð\8aJ\82­\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool COutputWave::open()\r
+{\r
+       // \83f\83o\83C\83X\82ð\8aJ\82­\r
+       // \8aJ\82­\83f\83o\83C\83X\82à\88ø\90\94\82Å\8ew\92è\82Å\82«\82é\82æ\82¤\82É\82·\82é\r
+       if(waveOutOpen(&m_hWaveOut, WAVE_MAPPER, &m_WaveFormat, reinterpret_cast<DWORD>(waveOutProc), reinterpret_cast<DWORD>(this), CALLBACK_FUNCTION) != MMSYSERR_NOERROR) {\r
+               //MessageBox(NULL, TEXT("WAVE\83f\83o\83C\83X\82Ì\83I\81[\83v\83\93\82É\8e¸\94s\82µ\82Ü\82µ\82½\81B"), NULL, MB_ICONWARNING);\r
+               throw "WAVE\83f\83o\83C\83X\82Ì\83I\81[\83v\83\93\82É\8e¸\94s\82µ\82Ü\82µ\82½\81B";\r
+               return false;\r
+       }\r
+\r
+       m_isOpen = true;\r
+\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83f\83o\83C\83X\82ð\95Â\82\82é\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool COutputWave::close()\r
+{\r
+       if(m_isOpen){\r
+               m_isOpen = false;\r
+               // \83f\83o\83C\83X\83N\83\8d\81[\83Y\8aÖ\90\94\r
+               waveOutClose(m_hWaveOut);\r
+       }\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// add wave buffer in queue\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool COutputWave::addWaveBuffer()\r
+{\r
+       while(!m_WaveHeaders.full() && !m_WaveBuffers.empty()){\r
+               // \83w\83b\83_\81[\82Æ\8ai\94[\97p\83f\81[\83^\82Ì\83|\83C\83\93\83^\82ð\8eæ\93¾\82·\82é\r
+               WAVEHDR* a_pWaveHeader = m_WaveHeaders.getWritePointer();\r
+               StructWaveBuffer* a_pWaveBuffer = m_WaveBuffers.getReadPointer();\r
+               // \8f\89\8aú\92l\82ð\83Z\83b\83g\82·\82é\r
+               a_pWaveHeader->lpData         = a_pWaveBuffer->m_pWaveBuffer;\r
+               a_pWaveHeader->dwBufferLength = a_pWaveBuffer->m_BufferSize;\r
+               a_pWaveHeader->dwFlags        = 0;\r
+               // \83|\83C\83\93\83^\82ð\8e\9f\82É\90i\82ß\82é\r
+               m_WaveHeaders.nextWriteBuffer();\r
+               m_WaveBuffers.nextReadBuffer();\r
+\r
+               if(a_pWaveHeader->lpData == NULL){\r
+                       return false;\r
+               }\r
+\r
+               // \83w\83b\83_\81[\82ð\8f\80\94õ\82·\82é\r
+               waveOutPrepareHeader(m_hWaveOut, a_pWaveHeader, sizeof(WAVEHDR));\r
+\r
+               // \8fo\97Í\81i\8dÄ\90\81j\82ð\8aJ\8en\82·\82é\r
+               waveOutWrite(m_hWaveOut, a_pWaveHeader, sizeof(WAVEHDR));\r
+       }\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \8fo\97Í\81i\8dÄ\90\81j\82ð\8aJ\8en\82·\82é\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool COutputWave::start()\r
+{\r
+       // \83f\83o\83C\83X\82ð\8aJ\82¢\82Ä\82¢\82È\82¢\82È\82çfalse\82ð\95Ô\82·\r
+       if(!m_isOpen){\r
+               return false;\r
+       }\r
+\r
+       addWaveBuffer();\r
+\r
+       m_isOutput = true;\r
+\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \8fo\97Í\81i\8dÄ\90\81j\82ð\92â\8e~\82·\82é\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool COutputWave::stop()\r
+{\r
+       // \8dÄ\90\92\86\82Å\82È\82¢\8fê\8d\87false\82ð\95Ô\82·\r
+       if(!m_isOutput){\r
+               return false;\r
+       }\r
+\r
+       waveOutReset(m_hWaveOut);\r
+       m_isOutput = false;\r
+\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \89¹\90º\83f\81[\83^\82ð\83Z\83b\83g\82·\82é\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool COutputWave::setWaveDataPointer(const StructWaveBuffer* in_pWaveBuffer)\r
+{\r
+       if(in_pWaveBuffer == NULL){\r
+               return false;\r
+       }\r
+\r
+       StructWaveBuffer* temp = m_WaveBuffers.getWritePointer();\r
+\r
+       if(temp == NULL){\r
+               return false;\r
+       }\r
+\r
+       temp->m_BufferSize = in_pWaveBuffer->m_BufferSize;\r
+       temp->m_RecorMilliSecond = in_pWaveBuffer->m_RecorMilliSecond;\r
+       for(unsigned int i = 0; i < in_pWaveBuffer->m_BufferSize; i++){\r
+               temp->m_pWaveBuffer[i] = in_pWaveBuffer->m_pWaveBuffer[i];\r
+       }\r
+\r
+       m_WaveBuffers.nextWriteBuffer();\r
+       return true;\r
+}\r
index b4356fa..7921ee1 100644 (file)
-// \8b\9e
-#ifndef INC_COutputWave
-#define INC_COutputWave
-
-// \83C\83\93\83N\83\8b\81[\83h\82Í\95K\82¸\95K\97v\82È\95¨\82¾\82¯
-// \93à\95\94\82Å\97\98\97p\82·\82é\82¾\82¯\82Ì\95¨\82Í\83\\81[\83X\82É\8bL\8fq
-
-// \8aÖ\90\94\96¼\82Í\83\8d\81[\83\8f\83L\83\83\83\81\83\8b\83P\81[\83X\82Æ\82·\82é
-
-
-#include "CWaveData.h"
-#include "CRingBuffer.h"
-
-#include <list>
-
-////////////////////////////////////////////////////////////////////////////////
-// COutputWave
-////////////////////////////////////////////////////////////////////////////////
-class COutputWave
-{
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83\81\83\93\83o\95Ï\90\94
-       ////////////////////////////////////////////////////////////////////////////////
-private:
-       // wave format
-       WAVEFORMATEX m_WaveFormat;
-       // Wave\83f\83o\83C\83X\83n\83\93\83h\83\8b
-       HWAVEOUT m_hWaveOut;
-       // Wave\83w\83b\83_\81[
-       typedef CRingBuffer<WAVEHDR> WaveHeaderTable;
-       WaveHeaderTable m_WaveHeaders;
-       // Wave\83o\83b\83t\83@
-       //typedef CRingBuffer<StructWaveBuffer> WaveBufferTable;
-       CWaveData m_WaveBuffers;
-       //char* m_pFinishWaveBuffer;
-
-
-       // \83f\83o\83C\83X\82ð\83I\81[\83v\83\93\82µ\82Ä\82¢\82é
-       bool m_isOpen;
-       // \8dÄ\90\92\86
-       bool m_isOutput;
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83R\83\93\83X\83g\83\89\83N\83^
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       COutputWave();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83f\83X\83g\83\89\83N\83^
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       virtual ~COutputWave();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94
-       ////////////////////////////////////////////////////////////////////////////////
-       // \8fo\97Í\83f\83o\83C\83X\82Ì\8fó\91Ô\82ð\92m\82ç\82¹\82é\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94
-       static void CALLBACK waveOutProc(HWAVEOUT in_hWaveOut, UINT in_Message, DWORD in_Instance, DWORD in_Param1, DWORD in_Param2);
-       void callbackWave(HWAVEOUT in_hWaveOut, UINT in_Message, DWORD in_Instance, DWORD in_Param1, DWORD in_Param2);
-
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \91\80\8dì\83\81\83\\83b\83h
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       // \8f\89\8aú\89»
-       void initialize();
-       // \83f\83o\83C\83X\82ð\8aJ\82­
-       bool open();
-       // \83f\83o\83C\83X\82ð\95Â\82\82é
-       bool close();
-protected:
-       // add wave buffer in queue
-       bool addWaveBuffer();
-public:
-       // \8fo\97Í\81i\8dÄ\90\81j\82ð\8aJ\8en\82·\82é
-       bool start();
-       // \8fo\97Í\81i\8dÄ\90\81j\82ð\92â\8e~\82·\82é
-       bool stop();
-       // \89¹\90º\83f\81[\83^\82ð\83Z\83b\83g\82·\82é
-       bool setWaveDataPointer(const StructWaveBuffer* in_pWaveBuffer);
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \91®\90«\83\81\83\\83b\83h
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83C\83e\83\8c\81[\83V\83\87\83\93
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \8fó\91Ô
-       ////////////////////////////////////////////////////////////////////////////////
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \89\89\8eZ\8eq
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \8f\83\90\88\89¼\91z\8aÖ\90\94\81A\92è\8b`\82Ì\82Ý\81i\94ñ\8eÀ\91\95\92ñ\8b\9f\81j
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \93à\95\94\83N\83\89\83X
-       ////////////////////////////////////////////////////////////////////////////////
-
-
-};
-
-#endif //INC_COutputWave
+// \8b\9e\r
+#ifndef INC_COutputWave\r
+#define INC_COutputWave\r
+\r
+// \83C\83\93\83N\83\8b\81[\83h\82Í\95K\82¸\95K\97v\82È\95¨\82¾\82¯\r
+// \93à\95\94\82Å\97\98\97p\82·\82é\82¾\82¯\82Ì\95¨\82Í\83\\81[\83X\82É\8bL\8fq\r
+\r
+// \8aÖ\90\94\96¼\82Í\83\8d\81[\83\8f\83L\83\83\83\81\83\8b\83P\81[\83X\82Æ\82·\82é\r
+\r
+\r
+#include "CWaveData.h"\r
+#include "CRingBuffer.h"\r
+\r
+#include <list>\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// COutputWave\r
+////////////////////////////////////////////////////////////////////////////////\r
+class COutputWave\r
+{\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83\81\83\93\83o\95Ï\90\94\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+private:\r
+       // wave format\r
+       WAVEFORMATEX m_WaveFormat;\r
+       // Wave\83f\83o\83C\83X\83n\83\93\83h\83\8b\r
+       HWAVEOUT m_hWaveOut;\r
+       // Wave\83w\83b\83_\81[\r
+       typedef CRingBuffer<WAVEHDR> WaveHeaderTable;\r
+       WaveHeaderTable m_WaveHeaders;\r
+       // Wave\83o\83b\83t\83@\r
+       //typedef CRingBuffer<StructWaveBuffer> WaveBufferTable;\r
+       CWaveData m_WaveBuffers;\r
+       //char* m_pFinishWaveBuffer;\r
+\r
+\r
+       // \83f\83o\83C\83X\82ð\83I\81[\83v\83\93\82µ\82Ä\82¢\82é\r
+       bool m_isOpen;\r
+       // \8dÄ\90\92\86\r
+       bool m_isOutput;\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83R\83\93\83X\83g\83\89\83N\83^\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       COutputWave();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83f\83X\83g\83\89\83N\83^\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       virtual ~COutputWave();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \8fo\97Í\83f\83o\83C\83X\82Ì\8fó\91Ô\82ð\92m\82ç\82¹\82é\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94\r
+       static void CALLBACK waveOutProc(HWAVEOUT in_hWaveOut, UINT in_Message, DWORD in_Instance, DWORD in_Param1, DWORD in_Param2);\r
+       void callbackWave(HWAVEOUT in_hWaveOut, UINT in_Message, DWORD in_Instance, DWORD in_Param1, DWORD in_Param2);\r
+\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \91\80\8dì\83\81\83\\83b\83h\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       // \8f\89\8aú\89»\r
+       void initialize();\r
+       // \83f\83o\83C\83X\82ð\8aJ\82­\r
+       bool open();\r
+       // \83f\83o\83C\83X\82ð\95Â\82\82é\r
+       bool close();\r
+protected:\r
+       // add wave buffer in queue\r
+       bool addWaveBuffer();\r
+public:\r
+       // \8fo\97Í\81i\8dÄ\90\81j\82ð\8aJ\8en\82·\82é\r
+       bool start();\r
+       // \8fo\97Í\81i\8dÄ\90\81j\82ð\92â\8e~\82·\82é\r
+       bool stop();\r
+       // \89¹\90º\83f\81[\83^\82ð\83Z\83b\83g\82·\82é\r
+       bool setWaveDataPointer(const StructWaveBuffer* in_pWaveBuffer);\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \91®\90«\83\81\83\\83b\83h\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83C\83e\83\8c\81[\83V\83\87\83\93\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \8fó\91Ô\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \89\89\8eZ\8eq\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \8f\83\90\88\89¼\91z\8aÖ\90\94\81A\92è\8b`\82Ì\82Ý\81i\94ñ\8eÀ\91\95\92ñ\8b\9f\81j\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \93à\95\94\83N\83\89\83X\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+\r
+\r
+};\r
+\r
+#endif //INC_COutputWave\r
index fc3000d..9b32a0a 100644 (file)
-// \8b\9e
-#ifndef INC_CRingBuffer
-#define INC_CRingBuffer
-
-
-#include <vector>
-
-////////////////////////////////////////////////////////////////////////////////
-// CRingBuffer
-////////////////////////////////////////////////////////////////////////////////
-template<typename T>
-class CRingBuffer
-{
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83\81\83\93\83o\95Ï\90\94
-       ////////////////////////////////////////////////////////////////////////////////
-private:
-       std::vector<T> m_Buffer;
-       int m_ReadPosition;
-       int m_WritePosition;
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83R\83\93\83X\83g\83\89\83N\83^
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       CRingBuffer()
-       {
-               m_ReadPosition = 0;
-               m_WritePosition = 0;
-       }
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83f\83X\83g\83\89\83N\83^
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       virtual ~CRingBuffer()
-       {
-               clear();
-       }
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \91\80\8dì\83\81\83\\83b\83h
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       bool allocate(unsigned int in_Size)
-       {
-               if(in_Size < 2){
-                       return false;
-               }
-
-               m_Buffer.resize(in_Size);
-               m_ReadPosition = 0;
-               m_WritePosition = 0;
-               return true;
-       }
-
-       void clear()
-       {
-               m_Buffer.clear();
-               m_ReadPosition = 0;
-               m_WritePosition = 0;
-       }
-
-       bool nextReadBuffer()
-       {
-               if(empty()){
-                       return false;
-               }
-
-               m_ReadPosition = (m_ReadPosition + 1) % m_Buffer.size();
-               return true;
-       }
-
-       bool nextWriteBuffer()
-       {
-               if(full()){
-                       return false;
-               }
-
-               m_WritePosition = (m_WritePosition + 1) % m_Buffer.size();
-               return true;
-       }
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \91®\90«\83\81\83\\83b\83h
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       size_t size() const
-       {
-               return m_Buffer.size();
-       }
-
-       T* at(size_t in_Index)
-       {
-               return &m_Buffer[in_Index];
-       }
-
-       const T* at(size_t in_Index) const
-       {
-               return &m_Buffer[in_Index];
-       }
-
-       T* getReadPointer()
-       {
-               if(empty()){
-                       return NULL;
-               }
-               return &m_Buffer[m_ReadPosition];
-       }
-
-       const T* getReadPointer() const
-       {
-               return &m_Buffer[m_ReadPosition];
-       }
-
-       T* getWritePointer()
-       {
-               return &m_Buffer[m_WritePosition];
-       }
-
-       const T* getWritePointer() const
-       {
-               return &m_Buffer[m_WritePosition];
-       }
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83C\83e\83\8c\81[\83V\83\87\83\93
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \8fó\91Ô
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       // check if the buffer is full
-       bool full() const
-       {
-               return m_ReadPosition == (m_WritePosition + 1) % m_Buffer.size();
-       }
-
-       // check if the buffer is empty
-       bool empty() const
-       {
-               return m_ReadPosition == m_WritePosition;;
-       }
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \89\89\8eZ\8eq
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \8f\83\90\88\89¼\91z\8aÖ\90\94\81A\92è\8b`\82Ì\82Ý\81i\94ñ\8eÀ\91\95\92ñ\8b\9f\81j
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \93à\95\94\83N\83\89\83X
-       ////////////////////////////////////////////////////////////////////////////////
-
-
-};
-
-#endif //INC_CRingBuffer
+// \8b\9e\r
+#ifndef INC_CRingBuffer\r
+#define INC_CRingBuffer\r
+\r
+\r
+#include <vector>\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// CRingBuffer\r
+////////////////////////////////////////////////////////////////////////////////\r
+template<typename T>\r
+class CRingBuffer\r
+{\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83\81\83\93\83o\95Ï\90\94\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+private:\r
+       std::vector<T> m_Buffer;\r
+       int m_ReadPosition;\r
+       int m_WritePosition;\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83R\83\93\83X\83g\83\89\83N\83^\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       CRingBuffer()\r
+       {\r
+               m_ReadPosition = 0;\r
+               m_WritePosition = 0;\r
+       }\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83f\83X\83g\83\89\83N\83^\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       virtual ~CRingBuffer()\r
+       {\r
+               clear();\r
+       }\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \91\80\8dì\83\81\83\\83b\83h\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       bool allocate(unsigned int in_Size)\r
+       {\r
+               if(in_Size < 2){\r
+                       return false;\r
+               }\r
+\r
+               m_Buffer.resize(in_Size);\r
+               m_ReadPosition = 0;\r
+               m_WritePosition = 0;\r
+               return true;\r
+       }\r
+\r
+       void clear()\r
+       {\r
+               m_Buffer.clear();\r
+               m_ReadPosition = 0;\r
+               m_WritePosition = 0;\r
+       }\r
+\r
+       bool nextReadBuffer()\r
+       {\r
+               if(empty()){\r
+                       return false;\r
+               }\r
+\r
+               m_ReadPosition = (m_ReadPosition + 1) % m_Buffer.size();\r
+               return true;\r
+       }\r
+\r
+       bool nextWriteBuffer()\r
+       {\r
+               if(full()){\r
+                       return false;\r
+               }\r
+\r
+               m_WritePosition = (m_WritePosition + 1) % m_Buffer.size();\r
+               return true;\r
+       }\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \91®\90«\83\81\83\\83b\83h\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       size_t size() const\r
+       {\r
+               return m_Buffer.size();\r
+       }\r
+\r
+       T* at(size_t in_Index)\r
+       {\r
+               return &m_Buffer[in_Index];\r
+       }\r
+\r
+       const T* at(size_t in_Index) const\r
+       {\r
+               return &m_Buffer[in_Index];\r
+       }\r
+\r
+       T* getReadPointer()\r
+       {\r
+               if(empty()){\r
+                       return NULL;\r
+               }\r
+               return &m_Buffer[m_ReadPosition];\r
+       }\r
+\r
+       const T* getReadPointer() const\r
+       {\r
+               return &m_Buffer[m_ReadPosition];\r
+       }\r
+\r
+       T* getWritePointer()\r
+       {\r
+               return &m_Buffer[m_WritePosition];\r
+       }\r
+\r
+       const T* getWritePointer() const\r
+       {\r
+               return &m_Buffer[m_WritePosition];\r
+       }\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83C\83e\83\8c\81[\83V\83\87\83\93\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \8fó\91Ô\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       // check if the buffer is full\r
+       bool full() const\r
+       {\r
+               return m_ReadPosition == (m_WritePosition + 1) % m_Buffer.size();\r
+       }\r
+\r
+       // check if the buffer is empty\r
+       bool empty() const\r
+       {\r
+               return m_ReadPosition == m_WritePosition;;\r
+       }\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \89\89\8eZ\8eq\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \8f\83\90\88\89¼\91z\8aÖ\90\94\81A\92è\8b`\82Ì\82Ý\81i\94ñ\8eÀ\91\95\92ñ\8b\9f\81j\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \93à\95\94\83N\83\89\83X\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+\r
+\r
+};\r
+\r
+#endif //INC_CRingBuffer\r
index 230790a..160fed8 100644 (file)
-#include "CServerConnection.h"
-
-
-////////////////////////////////////////////////////////////////////////////////
-// \83R\83\93\83X\83g\83\89\83N\83^
-////////////////////////////////////////////////////////////////////////////////
-CServerConnection::CServerConnection()
-{
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \83f\83X\83g\83\89\83N\83^
-////////////////////////////////////////////////////////////////////////////////
-CServerConnection::~CServerConnection()
-{
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// initialize
-////////////////////////////////////////////////////////////////////////////////
-bool CServerConnection::initialize()
-{
-       CSocket::initialize();
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// send
-////////////////////////////////////////////////////////////////////////////////
-bool CServerConnection::send(const CommunicationData* in_pCommunicationData)
-{
-       // \83T\83C\83Y\82Í\8c\88\82ß\91Å\82¿
-       if(::send(m_Socket, reinterpret_cast<const char*>(in_pCommunicationData), MAX_COMMUNICATION_DATA_LENGTH, 0) == SOCKET_ERROR){
-               return false;
-       }
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// receive
-////////////////////////////////////////////////////////////////////////////////
-bool CServerConnection::receive(CommunicationData** out_ppCommunicationData)
-{
-       if(m_Buffer.empty()){
-               return false;
-       }
-
-       *out_ppCommunicationData = reinterpret_cast<CommunicationData*>(m_Buffer.getReadPointer()->m_Buffer);
-       m_Buffer.nextReadBuffer();
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \89¹\90º\91\97\90M
-////////////////////////////////////////////////////////////////////////////////
-bool CServerConnection::sendVoice(char* in_pVoice, int in_Length, bool in_isEnd)
-{
-       CommunicationData a_SendData;
-
-       if(sizeof(a_SendData.m_Data.m_Voice.m_Stream) < in_Length){
-               return false;
-       }
-
-       a_SendData.m_DataType = 'v';
-       for(int i = 0; i < in_Length; i++){
-               a_SendData.m_Data.m_Voice.m_Stream[i] = in_pVoice[i];
-       }
-       a_SendData.m_Data.m_Voice.m_Length = in_Length;
-       a_SendData.m_Data.m_Voice.m_isEnd = in_isEnd;
-       send(&a_SendData);
-       return true;
-}
+#include "CServerConnection.h"\r
+\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83R\83\93\83X\83g\83\89\83N\83^\r
+////////////////////////////////////////////////////////////////////////////////\r
+CServerConnection::CServerConnection()\r
+{\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83f\83X\83g\83\89\83N\83^\r
+////////////////////////////////////////////////////////////////////////////////\r
+CServerConnection::~CServerConnection()\r
+{\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// initialize\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CServerConnection::initialize()\r
+{\r
+       CSocket::initialize();\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// send\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CServerConnection::send(const CommunicationData* in_pCommunicationData)\r
+{\r
+       // \83T\83C\83Y\82Í\8c\88\82ß\91Å\82¿\r
+       if(::send(m_Socket, reinterpret_cast<const char*>(in_pCommunicationData), MAX_COMMUNICATION_DATA_LENGTH, 0) == SOCKET_ERROR){\r
+               return false;\r
+       }\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// receive\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CServerConnection::receive(CommunicationData** out_ppCommunicationData)\r
+{\r
+       if(m_Buffer.empty()){\r
+               return false;\r
+       }\r
+\r
+       *out_ppCommunicationData = reinterpret_cast<CommunicationData*>(m_Buffer.getReadPointer()->m_Buffer);\r
+       m_Buffer.nextReadBuffer();\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \91\97\90M\8aÖ\90\94 \83\8d\83O\83C\83\93\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CServerConnection::sendLogin()\r
+{\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \91\97\90M\8aÖ\90\94 \83\8d\83O\83A\83E\83g\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CServerConnection::sendLogout()\r
+{\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \91\97\90M\8aÖ\90\94 \88ê\94Ê\83R\83}\83\93\83h\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CServerConnection::sendGeneralCommand(char kind)\r
+{\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \91\97\90M\8aÖ\90\94 \83A\83N\83V\83\87\83\93\83R\83}\83\93\83h\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CServerConnection::sendActionCommand(char kind)\r
+{\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \91\97\90M\8aÖ\90\94 \89¹\90º\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CServerConnection::sendVoice(char* in_pVoice, int in_Length, bool in_isEnd)\r
+{\r
+       CommunicationData a_SendData;\r
+\r
+       if(sizeof(a_SendData.m_Data.m_Voice.m_Stream) < in_Length){\r
+               return false;\r
+       }\r
+\r
+       a_SendData.m_DataType = 'v';\r
+       for(int i = 0; i < in_Length; i++){\r
+               a_SendData.m_Data.m_Voice.m_Stream[i] = in_pVoice[i];\r
+       }\r
+       a_SendData.m_Data.m_Voice.m_Length = in_Length;\r
+       a_SendData.m_Data.m_Voice.m_isEnd = in_isEnd;\r
+       send(&a_SendData);\r
+       return true;\r
+}\r
index 8bc8306..58f162c 100644 (file)
@@ -1,77 +1,91 @@
-#ifndef INC_CServerConnection
-#define INC_CServerConnection
-
-// \83C\83\93\83N\83\8b\81[\83h\82Í\95K\82¸\95K\97v\82È\95¨\82¾\82¯
-// \93à\95\94\82Å\97\98\97p\82·\82é\82¾\82¯\82Ì\95¨\82Í\83\\81[\83X\82É\8bL\8fq
-#include "CSocket.h"
-#include "Data.h"
-
-// \8aÖ\90\94\96¼\82Í\83\8d\81[\83\8f\83L\83\83\83\81\83\8b\83P\81[\83X\82Æ\82·\82é
-
-////////////////////////////////////////////////////////////////////////////////
-// CServerConnection
-// \92Ê\90M\97p\83N\83\89\83X
-// internetcity\97p\82Ì\92Ê\90M\97p
-// \83R\83}\83\93\83h\82È\82çTCP\81A\89¹\90º\82È\82çUDP\82ð\8eg\97p\82·\82é
-// \8d\\95\89ð\90Í\82Ì\8b@\94\\82ð\8eÀ\8c»\82·\82é
-// \8f\88\97\9d\82É\82©\82©\82í\82é\93à\97e\82Í\8bL\8fq\82µ\82È\82¢
-////////////////////////////////////////////////////////////////////////////////
-class CServerConnection : public CSocket
-{
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83\81\83\93\83o\95Ï\90\94
-       ////////////////////////////////////////////////////////////////////////////////
-private:
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83R\83\93\83X\83g\83\89\83N\83^
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       CServerConnection();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83f\83X\83g\83\89\83N\83^
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       ~CServerConnection();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \91\80\8dì\83\81\83\\83b\83h
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       // initialize
-       bool initialize();
-       // send
-       bool send(const CommunicationData* in_pCommunicationData);
-       // receive
-       bool receive(CommunicationData** out_ppCommunicationData);
-       // \89¹\90º\91\97\90M
-       bool sendVoice(char* in_pVoice, int in_Length, bool in_isEnd);
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \91®\90«\83\81\83\\83b\83h
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83C\83e\83\8c\81[\83V\83\87\83\93
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \8fó\91Ô
-       ////////////////////////////////////////////////////////////////////////////////
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \89\89\8eZ\8eq
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \8f\83\90\88\89¼\91z\8aÖ\90\94\81A\92è\8b`\82Ì\82Ý\81i\94ñ\8eÀ\91\95\92ñ\8b\9f\81j
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \93à\95\94\83N\83\89\83X
-       ////////////////////////////////////////////////////////////////////////////////
-
-
-};
-
-#endif //INC_CServerConnection
+#ifndef INC_CServerConnection\r
+#define INC_CServerConnection\r
+\r
+// \83C\83\93\83N\83\8b\81[\83h\82Í\95K\82¸\95K\97v\82È\95¨\82¾\82¯\r
+// \93à\95\94\82Å\97\98\97p\82·\82é\82¾\82¯\82Ì\95¨\82Í\83\\81[\83X\82É\8bL\8fq\r
+#include "CSocket.h"\r
+#include "Data.h"\r
+\r
+// \8aÖ\90\94\96¼\82Í\83\8d\81[\83\8f\83L\83\83\83\81\83\8b\83P\81[\83X\82Æ\82·\82é\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// CServerConnection\r
+// \92Ê\90M\97p\83N\83\89\83X\r
+// internetcity\97p\82Ì\92Ê\90M\97p\r
+// \83R\83}\83\93\83h\82È\82çTCP\81A\89¹\90º\82È\82çUDP\82ð\8eg\97p\82·\82é\r
+// \8d\\95\89ð\90Í\82Ì\8b@\94\\82ð\8eÀ\8c»\82·\82é\r
+// \8f\88\97\9d\82É\82©\82©\82í\82é\93à\97e\82Í\8bL\8fq\82µ\82È\82¢\r
+// \95Ï\90\94\82Å\82Í\82È\82­\8aÖ\90\94\8c\8b\8d\87\82É\82·\82é\r
+////////////////////////////////////////////////////////////////////////////////\r
+class CServerConnection : public CSocket\r
+{\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83\81\83\93\83o\95Ï\90\94\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+private:\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83R\83\93\83X\83g\83\89\83N\83^\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       CServerConnection();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83f\83X\83g\83\89\83N\83^\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       ~CServerConnection();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \91\80\8dì\83\81\83\\83b\83h\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       // initialize\r
+       bool initialize();\r
+public:\r
+       // send\r
+       bool send(const CommunicationData* in_pCommunicationData);\r
+public:\r
+       // receive\r
+       bool receive(CommunicationData** out_ppCommunicationData);\r
+\r
+public:\r
+       // \91\97\90M\8aÖ\90\94\r
+       // \83\8d\83O\83C\83\93\r
+       bool sendLogin();\r
+       // \83\8d\83O\83A\83E\83g\r
+       bool sendLogout();\r
+       // \88ê\94Ê\83R\83}\83\93\83h\r
+       bool sendGeneralCommand(char kind);\r
+       // \83A\83N\83V\83\87\83\93\83R\83}\83\93\83h\r
+       bool sendActionCommand(char kind);\r
+       // \89¹\90º\r
+       bool sendVoice(char* in_pVoice, int in_Length, bool in_isEnd);\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \91®\90«\83\81\83\\83b\83h\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83C\83e\83\8c\81[\83V\83\87\83\93\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \8fó\91Ô\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \89\89\8eZ\8eq\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \8f\83\90\88\89¼\91z\8aÖ\90\94\81A\92è\8b`\82Ì\82Ý\81i\94ñ\8eÀ\91\95\92ñ\8b\9f\81j\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \93à\95\94\83N\83\89\83X\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+\r
+\r
+};\r
+\r
+#endif //INC_CServerConnection\r
index 4046c79..661510d 100644 (file)
-#include <winsock2.h>
-#include <iostream>
-
-#include "CServerSocket.h"
-
-////////////////////////////////////////////////////////////////////////////////
-// \83R\83\93\83X\83g\83\89\83N\83^
-////////////////////////////////////////////////////////////////////////////////
-CServerSocket::CServerSocket()
-{
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \83f\83X\83g\83\89\83N\83^
-////////////////////////////////////////////////////////////////////////////////
-CServerSocket::~CServerSocket()
-{
-       uninitialize();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \8f\89\8aú\89»
-////////////////////////////////////////////////////////////////////////////////
-bool CServerSocket::initialize()
-{
-       // \82Ç\82Á\82©\82Å\83V\83\93\83O\83\8b\83g\83\93\82ð\8eg\82Á\82Ä\8f\89\8aú\89»\82µ\82Ä\82¨\82­
-       int a_Error = WSAStartup(MAKEWORD(2,0), &m_WsaData);
-       if(a_Error != 0){
-               switch(a_Error){
-               case WSASYSNOTREADY:
-                       throw "WSASYSNOTREADY";
-                       break;
-               case WSAVERNOTSUPPORTED:
-                       throw "WSAVERNOTSUPPORTED";
-                       break;
-               case WSAEINPROGRESS:
-                       throw "WSAEINPROGRESS";
-                       break;
-               case WSAEPROCLIM:
-                       throw "WSAEPROCLIM";
-                       break;
-               case WSAEFAULT:
-                       throw "WSAEFAULT";
-                       break;
-               }
-               return false;
-       }
-
-       /*
-       std::cout << "\83o\81[\83W\83\87\83\93 = " << static_cast<int>(wsaData.wHighVersion) << "." << static_cast<int>(wsaData.wHighVersion >> 8) << "\n"
-                 << "description = " << wsaData.szDescription << "\n"
-                 << "status = " << wsaData.szSystemStatus << "\n" << std::endl;
-       */
-
-       m_ServerSocket = socket(AF_INET, SOCK_STREAM, 0);
-       if(m_ServerSocket == INVALID_SOCKET){
-               //std::cout << "socket failed: " << WSAGetLastError() << std::endl;
-               return false;
-       }
-
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \94ñ\8f\89\8aú\89»
-////////////////////////////////////////////////////////////////////////////////
-bool CServerSocket::uninitialize()
-{
-       closePort();
-       WSACleanup();
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// open port
-////////////////////////////////////////////////////////////////////////////////
-bool CServerSocket::openPort()
-{
-       // \83\\83P\83b\83g\82Ì\90Ý\92è
-       m_ServerSocketAddress.sin_family = AF_INET;
-       m_ServerSocketAddress.sin_port = htons(12345);
-       m_ServerSocketAddress.sin_addr.S_un.S_addr = INADDR_ANY;
-       BOOL yes = 1;
-       setsockopt(m_ServerSocket, SOL_SOCKET, SO_REUSEADDR, (const char *)&yes, sizeof(yes));
-       bind(m_ServerSocket, reinterpret_cast<sockaddr*>(&m_ServerSocketAddress), sizeof(m_ServerSocketAddress));
-
-       // TCP\83N\83\89\83C\83A\83\93\83g\82©\82ç\82Ì\90Ú\91±\97v\8b\81\82ð\91Ò\82Ä\82é\8fó\91Ô\82É\82·\82é
-       listen(m_ServerSocket, 5);
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// close port
-////////////////////////////////////////////////////////////////////////////////
-bool CServerSocket::closePort()
-{
-       closesocket(m_ServerSocket);
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// accept
-////////////////////////////////////////////////////////////////////////////////
-bool CServerSocket::accept(CSocket* io_pSocket)
-{
-       try{
-               m_NonConnectedSockets.push_back(io_pSocket);
-       }
-       catch(...){
-               return false;
-       }
-       if(!m_isExist){
-               start(true);
-       }
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \83N\83\89\83C\83A\83\93\83g\82©\82ç\82Ì\90Ú\91±\82ð\91Ò\82Â
-////////////////////////////////////////////////////////////////////////////////
-void CServerSocket::run()
-{
-       // TCP\83N\83\89\83C\83A\83\93\83g\82©\82ç\82Ì\90Ú\91±\97v\8b\81\82ð\8eó\82¯\95t\82¯\82é
-       if(!m_NonConnectedSockets.empty()){
-               SOCKET a_ClientSocket;
-               sockaddr_in a_ClientSocketAddress;
-               int a_Length = sizeof(a_ClientSocketAddress);
-
-               a_ClientSocket = ::accept(m_ServerSocket, reinterpret_cast<sockaddr*>(&a_ClientSocketAddress), &a_Length);
-               if(a_ClientSocket == INVALID_SOCKET){
-                       m_doLoop = false;
-                       return;
-               }
-
-               std::cout << "accepted connection from " << inet_ntoa(a_ClientSocketAddress.sin_addr) << ", port = " << ntohs(a_ClientSocketAddress.sin_port) << std::endl;
-
-               // \96¢\90Ú\91±\82©\82ç\90Ú\91±\8dÏ\82Ý\82É\88Ú\93®\82·\82é
-               m_NonConnectedSockets.front()->connection(&a_ClientSocket, &a_ClientSocketAddress);
-               m_ConnectedSockets.push_back(m_NonConnectedSockets.front());
-               m_NonConnectedSockets.pop_front();
-       }
-
-       // \90Ú\91±\8dÏ\82Ý\82Ì\92\86\82©\82ç\90Ú\91±\82ª\8fI\97¹\82µ\82½\82à\82Ì\82ð\92T\8dõ\82µ\81A\96¢\90Ú\91±\82É\88Ú\93®\82·\82é
-       // \90Ú\91±\82ª\8fI\97¹\82µ\82Ä\82­\82ê\82½CSocket\82ª\92Ê\92m\82µ\82Ä\82­\82ê\82é\82Æ\8cø\97¦\82ª\82æ\82¢
-       std::list<CSocket*>::iterator p = m_ConnectedSockets.begin();
-       const std::list<CSocket*>::iterator end = m_ConnectedSockets.end();
-       while(true){
-               if(p == end){
-                       break;
-               }
-
-               if(!(*p)->isConnect()){
-                       // \96¢\90Ú\91±
-                       m_NonConnectedSockets.push_back(*p);
-                       p = m_ConnectedSockets.erase(p);
-                       continue;
-               }
-               p++;
-       }
-}
+#include <winsock2.h>\r
+#include <iostream>\r
+\r
+#include "CServerSocket.h"\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83R\83\93\83X\83g\83\89\83N\83^\r
+////////////////////////////////////////////////////////////////////////////////\r
+CServerSocket::CServerSocket()\r
+{\r
+       m_PortNumber = 12345;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83f\83X\83g\83\89\83N\83^\r
+////////////////////////////////////////////////////////////////////////////////\r
+CServerSocket::~CServerSocket()\r
+{\r
+       uninitialize();\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \8f\89\8aú\89»\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CServerSocket::initialize()\r
+{\r
+       // \82Ç\82Á\82©\82Å\83V\83\93\83O\83\8b\83g\83\93\82ð\8eg\82Á\82Ä\8f\89\8aú\89»\82µ\82Ä\82¨\82­\r
+       int a_Error = WSAStartup(MAKEWORD(2,0), &m_WsaData);\r
+       if(a_Error != 0){\r
+               switch(a_Error){\r
+               case WSASYSNOTREADY:\r
+                       throw "WSASYSNOTREADY";\r
+                       break;\r
+               case WSAVERNOTSUPPORTED:\r
+                       throw "WSAVERNOTSUPPORTED";\r
+                       break;\r
+               case WSAEINPROGRESS:\r
+                       throw "WSAEINPROGRESS";\r
+                       break;\r
+               case WSAEPROCLIM:\r
+                       throw "WSAEPROCLIM";\r
+                       break;\r
+               case WSAEFAULT:\r
+                       throw "WSAEFAULT";\r
+                       break;\r
+               }\r
+               return false;\r
+       }\r
+\r
+       /*\r
+       std::cout << "\83o\81[\83W\83\87\83\93 = " << static_cast<int>(wsaData.wHighVersion) << "." << static_cast<int>(wsaData.wHighVersion >> 8) << "\n"\r
+                 << "description = " << wsaData.szDescription << "\n"\r
+                 << "status = " << wsaData.szSystemStatus << "\n" << std::endl;\r
+       */\r
+\r
+       m_ServerSocket = socket(AF_INET, SOCK_STREAM, 0);\r
+       if(m_ServerSocket == INVALID_SOCKET){\r
+               //std::cout << "socket failed: " << WSAGetLastError() << std::endl;\r
+               return false;\r
+       }\r
+\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \94ñ\8f\89\8aú\89»\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CServerSocket::uninitialize()\r
+{\r
+       closePort();\r
+       WSACleanup();\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// open port\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CServerSocket::openPort()\r
+{\r
+       // \83\\83P\83b\83g\82Ì\90Ý\92è\r
+       m_ServerSocketAddress.sin_family = AF_INET;\r
+       m_ServerSocketAddress.sin_port = htons(m_PortNumber);\r
+       m_ServerSocketAddress.sin_addr.S_un.S_addr = INADDR_ANY;\r
+       BOOL yes = 1;\r
+       setsockopt(m_ServerSocket, SOL_SOCKET, SO_REUSEADDR, (const char *)&yes, sizeof(yes));\r
+       bind(m_ServerSocket, reinterpret_cast<sockaddr*>(&m_ServerSocketAddress), sizeof(m_ServerSocketAddress));\r
+\r
+       // TCP\83N\83\89\83C\83A\83\93\83g\82©\82ç\82Ì\90Ú\91±\97v\8b\81\82ð\91Ò\82Ä\82é\8fó\91Ô\82É\82·\82é\r
+       listen(m_ServerSocket, 5);\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// close port\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CServerSocket::closePort()\r
+{\r
+       closesocket(m_ServerSocket);\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// accept\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CServerSocket::accept(CSocket* io_pSocket)\r
+{\r
+       try{\r
+               m_NonConnectedSockets.push_back(io_pSocket);\r
+       }\r
+       catch(...){\r
+               return false;\r
+       }\r
+       if(!m_isExist){\r
+               start(true);\r
+       }\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83N\83\89\83C\83A\83\93\83g\82©\82ç\82Ì\90Ú\91±\82ð\91Ò\82Â\r
+////////////////////////////////////////////////////////////////////////////////\r
+void CServerSocket::run()\r
+{\r
+       // TCP\83N\83\89\83C\83A\83\93\83g\82©\82ç\82Ì\90Ú\91±\97v\8b\81\82ð\8eó\82¯\95t\82¯\82é\r
+       if(!m_NonConnectedSockets.empty()){\r
+               SOCKET a_ClientSocket;\r
+               sockaddr_in a_ClientSocketAddress;\r
+               int a_Length = sizeof(a_ClientSocketAddress);\r
+\r
+               a_ClientSocket = ::accept(m_ServerSocket, reinterpret_cast<sockaddr*>(&a_ClientSocketAddress), &a_Length);\r
+               if(a_ClientSocket == INVALID_SOCKET){\r
+                       m_doLoop = false;\r
+                       return;\r
+               }\r
+\r
+               std::cout << "accepted connection from " << inet_ntoa(a_ClientSocketAddress.sin_addr) << ", port = " << ntohs(a_ClientSocketAddress.sin_port) << std::endl;\r
+\r
+               // \96¢\90Ú\91±\82©\82ç\90Ú\91±\8dÏ\82Ý\82É\88Ú\93®\82·\82é\r
+               m_NonConnectedSockets.front()->connection(&a_ClientSocket, &a_ClientSocketAddress);\r
+               m_ConnectedSockets.push_back(m_NonConnectedSockets.front());\r
+               m_NonConnectedSockets.pop_front();\r
+       }\r
+\r
+       // \90Ú\91±\8dÏ\82Ý\82Ì\92\86\82©\82ç\90Ú\91±\82ª\8fI\97¹\82µ\82½\82à\82Ì\82ð\92T\8dõ\82µ\81A\96¢\90Ú\91±\82É\88Ú\93®\82·\82é\r
+       // \90Ú\91±\82ª\8fI\97¹\82µ\82Ä\82­\82ê\82½CSocket\82ª\92Ê\92m\82µ\82Ä\82­\82ê\82é\82Æ\8cø\97¦\82ª\82æ\82¢\r
+       std::list<CSocket*>::iterator p = m_ConnectedSockets.begin();\r
+       const std::list<CSocket*>::iterator end = m_ConnectedSockets.end();\r
+       while(true){\r
+               if(p == end){\r
+                       break;\r
+               }\r
+\r
+               if(!(*p)->isConnect()){\r
+                       // \96¢\90Ú\91±\r
+                       m_NonConnectedSockets.push_back(*p);\r
+                       p = m_ConnectedSockets.erase(p);\r
+                       continue;\r
+               }\r
+               p++;\r
+       }\r
+}\r
index 234b1fb..ad00f21 100644 (file)
@@ -1,94 +1,98 @@
-#ifndef INC_CServerSocket
-#define INC_CServerSocket
-
-// \83C\83\93\83N\83\8b\81[\83h\82Í\95K\82¸\95K\97v\82È\95¨\82¾\82¯
-// \93à\95\94\82Å\97\98\97p\82·\82é\82¾\82¯\82Ì\95¨\82Í\83\\81[\83X\82É\8bL\8fq
-// winsock2.h\82Íwindows.h\82æ\82è\90æ\82É\83C\83\93\83N\83\8b\81[\83h\82µ\82È\82¯\82ê\82Î\82È\82ç\82È\82¢\82ç\82µ\82¢
-//#include <winsock2.h>
-#include "CThread.h"
-#include "CSocket.h"
-
-#include <list>
-
-// \8aÖ\90\94\96¼\82Í\83\8d\81[\83\8f\83L\83\83\83\81\83\8b\83P\81[\83X\82Æ\82·\82é
-
-////////////////////////////////////////////////////////////////////////////////
-// CServerSocket
-////////////////////////////////////////////////////////////////////////////////
-class CServerSocket : public CThread
-{
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83\81\83\93\83o\95Ï\90\94
-       ////////////////////////////////////////////////////////////////////////////////
-private:
-       WSADATA m_WsaData;
-       // \8e©\95ª\8e©\90g\82Ì\83\\83P\83b\83g
-       SOCKET m_ServerSocket;
-       sockaddr_in m_ServerSocketAddress;
-
-       std::list<CSocket*> m_NonConnectedSockets;
-       std::list<CSocket*> m_ConnectedSockets;
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83R\83\93\83X\83g\83\89\83N\83^
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       CServerSocket();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83f\83X\83g\83\89\83N\83^
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       ~CServerSocket();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \91\80\8dì\83\81\83\\83b\83h
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       // \8f\89\8aú\89»
-       bool initialize();
-       // \94ñ\8f\89\8aú\89»
-       bool uninitialize();
-       // open port
-       bool openPort();
-       // close port
-       bool closePort();
-       // accept
-       bool accept(CSocket* io_pSocket);
-
-protected:
-       // \83X\83\8c\83b\83h\83\8b\81[\83v
-       void run();
-
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \91®\90«\83\81\83\\83b\83h
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       // \90Ú\91±\8b\96\89Â\82µ\82½\83N\83\89\83C\83A\83\93\83g\82ð\8eæ\93¾\82·\82é
-       //CSocket* getAcceptSocket();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83C\83e\83\8c\81[\83V\83\87\83\93
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \8fó\91Ô
-       ////////////////////////////////////////////////////////////////////////////////
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \89\89\8eZ\8eq
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \8f\83\90\88\89¼\91z\8aÖ\90\94\81A\92è\8b`\82Ì\82Ý\81i\94ñ\8eÀ\91\95\92ñ\8b\9f\81j
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \93à\95\94\83N\83\89\83X
-       ////////////////////////////////////////////////////////////////////////////////
-
-
-};
-
-#endif //INC_CServerSocket
+#ifndef INC_CServerSocket\r
+#define INC_CServerSocket\r
+\r
+// \83C\83\93\83N\83\8b\81[\83h\82Í\95K\82¸\95K\97v\82È\95¨\82¾\82¯\r
+// \93à\95\94\82Å\97\98\97p\82·\82é\82¾\82¯\82Ì\95¨\82Í\83\\81[\83X\82É\8bL\8fq\r
+// winsock2.h\82Íwindows.h\82æ\82è\90æ\82É\83C\83\93\83N\83\8b\81[\83h\82µ\82È\82¯\82ê\82Î\82È\82ç\82È\82¢\82ç\82µ\82¢\r
+//#include <winsock2.h>\r
+#include "CThread.h"\r
+#include "CSocket.h"\r
+\r
+#include <list>\r
+\r
+// \8aÖ\90\94\96¼\82Í\83\8d\81[\83\8f\83L\83\83\83\81\83\8b\83P\81[\83X\82Æ\82·\82é\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// CServerSocket\r
+////////////////////////////////////////////////////////////////////////////////\r
+class CServerSocket : public CThread\r
+{\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83\81\83\93\83o\95Ï\90\94\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+private:\r
+       WSADATA m_WsaData;\r
+       // \8e©\95ª\8e©\90g\82Ì\83\\83P\83b\83g\r
+       SOCKET m_ServerSocket;\r
+       sockaddr_in m_ServerSocketAddress;\r
+\r
+       std::list<CSocket*> m_NonConnectedSockets;\r
+       std::list<CSocket*> m_ConnectedSockets;\r
+\r
+       // \83|\81[\83g\94Ô\8d\86\r
+       unsigned short m_PortNumber;\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83R\83\93\83X\83g\83\89\83N\83^\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       CServerSocket();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83f\83X\83g\83\89\83N\83^\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       ~CServerSocket();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \91\80\8dì\83\81\83\\83b\83h\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       // \8f\89\8aú\89»\r
+       bool initialize();\r
+       // \94ñ\8f\89\8aú\89»\r
+       bool uninitialize();\r
+       // open port\r
+       bool openPort();\r
+       // close port\r
+       bool closePort();\r
+       // accept\r
+       bool accept(CSocket* io_pSocket);\r
+\r
+protected:\r
+       // \83X\83\8c\83b\83h\83\8b\81[\83v\r
+       void run();\r
+\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \91®\90«\83\81\83\\83b\83h\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       // \90Ú\91±\8b\96\89Â\82µ\82½\83N\83\89\83C\83A\83\93\83g\82ð\8eæ\93¾\82·\82é\r
+       //CSocket* getAcceptSocket();\r
+       unsigned short getPortNumber() { return m_PortNumber; }\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83C\83e\83\8c\81[\83V\83\87\83\93\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \8fó\91Ô\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \89\89\8eZ\8eq\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \8f\83\90\88\89¼\91z\8aÖ\90\94\81A\92è\8b`\82Ì\82Ý\81i\94ñ\8eÀ\91\95\92ñ\8b\9f\81j\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \93à\95\94\83N\83\89\83X\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+\r
+\r
+};\r
+\r
+#endif //INC_CServerSocket\r
index fb4009f..d6eb0bf 100644 (file)
-#include <winsock2.h>
-#include <iostream>
-
-#include "CSocket.h"
-
-////////////////////////////////////////////////////////////////////////////////
-// \83R\83\93\83X\83g\83\89\83N\83^
-////////////////////////////////////////////////////////////////////////////////
-CSocket::CSocket()
-{
-       m_Socket = INVALID_SOCKET;
-       m_isConnect = false;
-       m_Buffer.allocate(100);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \83f\83X\83g\83\89\83N\83^
-////////////////////////////////////////////////////////////////////////////////
-CSocket::~CSocket()
-{
-       uninitialize();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \8f\89\8aú\89»
-////////////////////////////////////////////////////////////////////////////////
-bool CSocket::initialize()
-{
-       int a_Error = WSAStartup(MAKEWORD(2,0), &m_WsaData);
-       if(a_Error != 0){
-               switch(a_Error){
-               case WSASYSNOTREADY:
-                       throw "WSASYSNOTREADY";
-                       break;
-               case WSAVERNOTSUPPORTED:
-                       throw "WSAVERNOTSUPPORTED";
-                       break;
-               case WSAEINPROGRESS:
-                       throw "WSAEINPROGRESS";
-                       break;
-               case WSAEPROCLIM:
-                       throw "WSAEPROCLIM";
-                       break;
-               case WSAEFAULT:
-                       throw "WSAEFAULT";
-                       break;
-               }
-               return false;
-       }
-
-       /*
-       std::cout << "\83o\81[\83W\83\87\83\93 = " << static_cast<int>(wsaData.wHighVersion) << "." << static_cast<int>(wsaData.wHighVersion >> 8) << "\n"
-                 << "description = " << wsaData.szDescription << "\n"
-                 << "status = " << wsaData.szSystemStatus << "\n" << std::endl;
-       */
-
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \94ñ\8f\89\8aú\89»
-////////////////////////////////////////////////////////////////////////////////
-bool CSocket::uninitialize()
-{
-       disconnection();
-       WSACleanup();
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// connection
-////////////////////////////////////////////////////////////////////////////////
-bool CSocket::connection(char* in_pIpAddress, unsigned short in_PortNumber)
-{
-       m_Socket = socket(AF_INET, SOCK_STREAM, 0);
-       if(m_Socket == INVALID_SOCKET){
-               //std::cout << "socket failed: " << WSAGetLastError() << std::endl;
-               return false;
-       }
-
-       m_SocketAddress.sin_family = AF_INET;
-       m_SocketAddress.sin_port = htons(in_PortNumber);
-       m_SocketAddress.sin_addr.S_un.S_addr = inet_addr(in_pIpAddress);
-       if(connect(m_Socket, reinterpret_cast<sockaddr*>(&m_SocketAddress), sizeof(m_SocketAddress)) == SOCKET_ERROR){
-               closesocket(m_Socket);
-               m_Socket = INVALID_SOCKET;
-               return false;
-       }
-       m_isConnect = true;
-
-       start(true);
-       return true;
-}
-
-bool CSocket::connection(SOCKET* io_pSocket, sockaddr_in* io_pSockAddress)
-{
-       m_Socket = *io_pSocket;
-       m_SocketAddress = *io_pSockAddress;
-       m_isConnect = true;
-
-       start(true);
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// disconnection
-////////////////////////////////////////////////////////////////////////////////
-bool CSocket::disconnection()
-{
-       if(closesocket(m_Socket) == SOCKET_ERROR){
-               return false;
-       }
-       m_Socket = INVALID_SOCKET;
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// shutdown
-////////////////////////////////////////////////////////////////////////////////
-bool CSocket::shutdown(unsigned int in_Kind)
-{
-       int a_Result = SOCKET_ERROR;
-       switch(in_Kind){
-       case 0:
-               // \91\97\90M\92\86\8e~
-               a_Result = ::shutdown(m_Socket, SD_SEND);
-               break;
-       case 1:
-               // \8eó\90M\92\86\8e~
-               a_Result = ::shutdown(m_Socket, SD_RECEIVE);
-               break;
-       case 2:
-               // \91\97\8eó\90M\92\86\8e~
-               a_Result = ::shutdown(m_Socket, SD_BOTH);
-               break;
-       default:
-               // \96³\8cø\82È\83R\83}\83\93\83h
-               throw "UNKNOWN COMMAND.";
-               break;
-       }
-       if(a_Result == SOCKET_ERROR){
-               return false;
-       }
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// send
-////////////////////////////////////////////////////////////////////////////////
-bool CSocket::send(const CommunicationBuffer* in_pCommunicationBuffer)
-{
-       if(::send(m_Socket, in_pCommunicationBuffer->m_Buffer, in_pCommunicationBuffer->m_Length, 0) == SOCKET_ERROR){
-               return false;
-       }
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// receive
-////////////////////////////////////////////////////////////////////////////////
-bool CSocket::receive(CommunicationBuffer** out_ppCommunicationBuffer)
-{
-       if(m_Buffer.empty()){
-               return false;
-       }
-
-       *out_ppCommunicationBuffer = m_Buffer.getReadPointer();
-       m_Buffer.nextReadBuffer();
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \8eó\90M\82ð\8ds\82¤
-////////////////////////////////////////////////////////////////////////////////
-void CSocket::run()
-{
-       if(!m_Buffer.full()){
-               m_Buffer.getWritePointer()->m_Length = recv(m_Socket, m_Buffer.getWritePointer()->m_Buffer, MAX_STRING_BUFFER_SIZE, 0);
-               if(m_Buffer.getWritePointer()->m_Length == 0){
-                       std::cout << "disconnection" << std::endl;
-                       m_isConnect = false;
-                       m_doLoop = false;
-                       return;
-               }
-               else if(m_Buffer.getWritePointer()->m_Length == SOCKET_ERROR){
-                       std::cout << "socket error" << std::endl;
-                       m_isConnect = false;
-                       m_doLoop = false;
-                       return;
-               }
-
-               //std::cout << m_Buffer.getWritePointer()->m_Buffer << std::endl;
-               m_Buffer.nextWriteBuffer();
-       }
-}
+#include <winsock2.h>\r
+#include <iostream>\r
+\r
+#include "CSocket.h"\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83R\83\93\83X\83g\83\89\83N\83^\r
+////////////////////////////////////////////////////////////////////////////////\r
+CSocket::CSocket()\r
+{\r
+       m_Socket = INVALID_SOCKET;\r
+       m_isConnect = false;\r
+       m_Buffer.allocate(100);\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83f\83X\83g\83\89\83N\83^\r
+////////////////////////////////////////////////////////////////////////////////\r
+CSocket::~CSocket()\r
+{\r
+       uninitialize();\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \8f\89\8aú\89»\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CSocket::initialize()\r
+{\r
+       int a_Error = WSAStartup(MAKEWORD(2,0), &m_WsaData);\r
+       if(a_Error != 0){\r
+               switch(a_Error){\r
+               case WSASYSNOTREADY:\r
+                       throw "WSASYSNOTREADY";\r
+                       break;\r
+               case WSAVERNOTSUPPORTED:\r
+                       throw "WSAVERNOTSUPPORTED";\r
+                       break;\r
+               case WSAEINPROGRESS:\r
+                       throw "WSAEINPROGRESS";\r
+                       break;\r
+               case WSAEPROCLIM:\r
+                       throw "WSAEPROCLIM";\r
+                       break;\r
+               case WSAEFAULT:\r
+                       throw "WSAEFAULT";\r
+                       break;\r
+               }\r
+               return false;\r
+       }\r
+\r
+       /*\r
+       std::cout << "\83o\81[\83W\83\87\83\93 = " << static_cast<int>(wsaData.wHighVersion) << "." << static_cast<int>(wsaData.wHighVersion >> 8) << "\n"\r
+                 << "description = " << wsaData.szDescription << "\n"\r
+                 << "status = " << wsaData.szSystemStatus << "\n" << std::endl;\r
+       */\r
+\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \94ñ\8f\89\8aú\89»\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CSocket::uninitialize()\r
+{\r
+       disconnection();\r
+       WSACleanup();\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// connection\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CSocket::connection(char* in_pIpAddress, unsigned short in_PortNumber)\r
+{\r
+       m_Socket = socket(AF_INET, SOCK_STREAM, 0);\r
+       if(m_Socket == INVALID_SOCKET){\r
+               //std::cout << "socket failed: " << WSAGetLastError() << std::endl;\r
+               return false;\r
+       }\r
+\r
+       m_SocketAddress.sin_family = AF_INET;\r
+       m_SocketAddress.sin_port = htons(in_PortNumber);\r
+       m_SocketAddress.sin_addr.S_un.S_addr = inet_addr(in_pIpAddress);\r
+       if(connect(m_Socket, reinterpret_cast<sockaddr*>(&m_SocketAddress), sizeof(m_SocketAddress)) == SOCKET_ERROR){\r
+               closesocket(m_Socket);\r
+               m_Socket = INVALID_SOCKET;\r
+               return false;\r
+       }\r
+       m_isConnect = true;\r
+\r
+       start(true);\r
+       return true;\r
+}\r
+\r
+bool CSocket::connection(SOCKET* io_pSocket, sockaddr_in* io_pSockAddress)\r
+{\r
+       m_Socket = *io_pSocket;\r
+       m_SocketAddress = *io_pSockAddress;\r
+       m_isConnect = true;\r
+\r
+       start(true);\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// disconnection\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CSocket::disconnection()\r
+{\r
+       if(closesocket(m_Socket) == SOCKET_ERROR){\r
+               return false;\r
+       }\r
+       m_Socket = INVALID_SOCKET;\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// shutdown\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CSocket::shutdown(unsigned int in_Kind)\r
+{\r
+       int a_Result = SOCKET_ERROR;\r
+       switch(in_Kind){\r
+       case 0:\r
+               // \91\97\90M\92\86\8e~\r
+               a_Result = ::shutdown(m_Socket, SD_SEND);\r
+               break;\r
+       case 1:\r
+               // \8eó\90M\92\86\8e~\r
+               a_Result = ::shutdown(m_Socket, SD_RECEIVE);\r
+               break;\r
+       case 2:\r
+               // \91\97\8eó\90M\92\86\8e~\r
+               a_Result = ::shutdown(m_Socket, SD_BOTH);\r
+               break;\r
+       default:\r
+               // \96³\8cø\82È\83R\83}\83\93\83h\r
+               throw "UNKNOWN COMMAND.";\r
+               break;\r
+       }\r
+       if(a_Result == SOCKET_ERROR){\r
+               return false;\r
+       }\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// send\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CSocket::send(const CommunicationBuffer* in_pCommunicationBuffer)\r
+{\r
+       if(::send(m_Socket, in_pCommunicationBuffer->m_Buffer, in_pCommunicationBuffer->m_Length, 0) == SOCKET_ERROR){\r
+               return false;\r
+       }\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// receive\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CSocket::receive(CommunicationBuffer** out_ppCommunicationBuffer)\r
+{\r
+       if(m_Buffer.empty()){\r
+               return false;\r
+       }\r
+\r
+       *out_ppCommunicationBuffer = m_Buffer.getReadPointer();\r
+       m_Buffer.nextReadBuffer();\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \8eó\90M\82ð\8ds\82¤\r
+////////////////////////////////////////////////////////////////////////////////\r
+void CSocket::run()\r
+{\r
+       if(!m_Buffer.full()){\r
+               m_Buffer.getWritePointer()->m_Length = recv(m_Socket, m_Buffer.getWritePointer()->m_Buffer, MAX_STRING_BUFFER_SIZE, 0);\r
+               if(m_Buffer.getWritePointer()->m_Length == 0){\r
+                       std::cout << "disconnection" << std::endl;\r
+                       m_isConnect = false;\r
+                       m_doLoop = false;\r
+                       return;\r
+               }\r
+               else if(m_Buffer.getWritePointer()->m_Length == SOCKET_ERROR){\r
+                       std::cout << "socket error" << std::endl;\r
+                       m_isConnect = false;\r
+                       m_doLoop = false;\r
+                       return;\r
+               }\r
+\r
+               //std::cout << m_Buffer.getWritePointer()->m_Buffer << std::endl;\r
+               m_Buffer.nextWriteBuffer();\r
+       }\r
+}\r
index f0cf91d..2312bae 100644 (file)
-#ifndef INC_CSocket
-#define INC_CSocket
-
-// \83C\83\93\83N\83\8b\81[\83h\82Í\95K\82¸\95K\97v\82È\95¨\82¾\82¯
-// \93à\95\94\82Å\97\98\97p\82·\82é\82¾\82¯\82Ì\95¨\82Í\83\\81[\83X\82É\8bL\8fq
-// winsock2.h\82Íwindows.h\82æ\82è\90æ\82É\83C\83\93\83N\83\8b\81[\83h\82µ\82È\82¯\82ê\82Î\82È\82ç\82È\82¢\82ç\82µ\82¢
-//#include <winsock2.h>
-#include "CThread.h"
-#include "CRingBuffer.h"
-
-// \8aÖ\90\94\96¼\82Í\83\8d\81[\83\8f\83L\83\83\83\81\83\8b\83P\81[\83X\82Æ\82·\82é
-
-const int MAX_STRING_BUFFER_SIZE = 256;
-
-struct CommunicationBuffer
-{
-       char m_Buffer[MAX_STRING_BUFFER_SIZE];
-       // \8ai\94[\82³\82ê\82Ä\82¢\82é\95\8e\9a\90\94
-       size_t m_Length;
-
-       CommunicationBuffer()
-       {
-               m_Length = 0;
-       }
-};
-
-////////////////////////////////////////////////////////////////////////////////
-// CSocket
-////////////////////////////////////////////////////////////////////////////////
-class CSocket : public CThread
-{
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83\81\83\93\83o\95Ï\90\94
-       ////////////////////////////////////////////////////////////////////////////////
-protected:
-       WSADATA m_WsaData;
-       SOCKET m_Socket;
-       sockaddr_in m_SocketAddress;
-
-       bool m_isConnect;
-       CRingBuffer<CommunicationBuffer> m_Buffer;
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83R\83\93\83X\83g\83\89\83N\83^
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       CSocket();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83f\83X\83g\83\89\83N\83^
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       virtual ~CSocket();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \91\80\8dì\83\81\83\\83b\83h
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       // \8f\89\8aú\89»
-       virtual bool initialize();
-       // \94ñ\8f\89\8aú\89»
-       virtual bool uninitialize();
-       // connection
-       virtual bool connection(char* in_pIpAddress = "127.0.0.1", unsigned short in_PortNumber = 12345);
-       virtual bool connection(SOCKET* io_pSocket, sockaddr_in* io_pSockAddress);
-       // disconnection
-       virtual bool disconnection();
-       // shutdown
-       virtual bool shutdown(unsigned int in_Kind);
-       // send
-       virtual bool send(const CommunicationBuffer* in_pCommunicationBuffer);
-       // receive
-       virtual bool receive(CommunicationBuffer** out_ppCommunicationBuffer);
-
-protected:
-       // \83X\83\8c\83b\83h\83\8b\81[\83v
-       void run();
-
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \91®\90«\83\81\83\\83b\83h
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       SOCKET* getSocket()
-       {
-               return &m_Socket;
-       }
-
-       sockaddr* getSocketAddress()
-       {
-               return reinterpret_cast<sockaddr*>(&m_SocketAddress);
-       }
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83C\83e\83\8c\81[\83V\83\87\83\93
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \8fó\91Ô
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       bool isConnect() const
-       {
-               return m_isConnect;
-       }
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \89\89\8eZ\8eq
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \8f\83\90\88\89¼\91z\8aÖ\90\94\81A\92è\8b`\82Ì\82Ý\81i\94ñ\8eÀ\91\95\92ñ\8b\9f\81j
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \93à\95\94\83N\83\89\83X
-       ////////////////////////////////////////////////////////////////////////////////
-
-
-};
-
-#endif //INC_CSocket
+#ifndef INC_CSocket\r
+#define INC_CSocket\r
+\r
+// \83C\83\93\83N\83\8b\81[\83h\82Í\95K\82¸\95K\97v\82È\95¨\82¾\82¯\r
+// \93à\95\94\82Å\97\98\97p\82·\82é\82¾\82¯\82Ì\95¨\82Í\83\\81[\83X\82É\8bL\8fq\r
+// winsock2.h\82Íwindows.h\82æ\82è\90æ\82É\83C\83\93\83N\83\8b\81[\83h\82µ\82È\82¯\82ê\82Î\82È\82ç\82È\82¢\82ç\82µ\82¢\r
+//#include <winsock2.h>\r
+#include "CThread.h"\r
+#include "CRingBuffer.h"\r
+\r
+// \8aÖ\90\94\96¼\82Í\83\8d\81[\83\8f\83L\83\83\83\81\83\8b\83P\81[\83X\82Æ\82·\82é\r
+\r
+const int MAX_STRING_BUFFER_SIZE = 256;\r
+\r
+struct CommunicationBuffer\r
+{\r
+       char m_Buffer[MAX_STRING_BUFFER_SIZE];\r
+       // \8ai\94[\82³\82ê\82Ä\82¢\82é\95\8e\9a\90\94\r
+       size_t m_Length;\r
+\r
+       CommunicationBuffer()\r
+       {\r
+               m_Length = 0;\r
+       }\r
+};\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// CSocket\r
+////////////////////////////////////////////////////////////////////////////////\r
+class CSocket : public CThread\r
+{\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83\81\83\93\83o\95Ï\90\94\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+protected:\r
+       WSADATA m_WsaData;\r
+       SOCKET m_Socket;\r
+       sockaddr_in m_SocketAddress;\r
+\r
+       bool m_isConnect;\r
+       CRingBuffer<CommunicationBuffer> m_Buffer;\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83R\83\93\83X\83g\83\89\83N\83^\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       CSocket();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83f\83X\83g\83\89\83N\83^\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       virtual ~CSocket();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \91\80\8dì\83\81\83\\83b\83h\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       // \8f\89\8aú\89»\r
+       virtual bool initialize();\r
+       // \94ñ\8f\89\8aú\89»\r
+       virtual bool uninitialize();\r
+       // connection\r
+       virtual bool connection(char* in_pIpAddress = "127.0.0.1", unsigned short in_PortNumber = 12345);\r
+       virtual bool connection(SOCKET* io_pSocket, sockaddr_in* io_pSockAddress);\r
+       // disconnection\r
+       virtual bool disconnection();\r
+       // shutdown\r
+       virtual bool shutdown(unsigned int in_Kind);\r
+       // send\r
+       virtual bool send(const CommunicationBuffer* in_pCommunicationBuffer);\r
+       // receive\r
+       virtual bool receive(CommunicationBuffer** out_ppCommunicationBuffer);\r
+\r
+protected:\r
+       // \83X\83\8c\83b\83h\83\8b\81[\83v\r
+       void run();\r
+\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \91®\90«\83\81\83\\83b\83h\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       SOCKET* getSocket()\r
+       {\r
+               return &m_Socket;\r
+       }\r
+\r
+       sockaddr* getSocketAddress()\r
+       {\r
+               return reinterpret_cast<sockaddr*>(&m_SocketAddress);\r
+       }\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83C\83e\83\8c\81[\83V\83\87\83\93\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \8fó\91Ô\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       bool isConnect() const\r
+       {\r
+               return m_isConnect;\r
+       }\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \89\89\8eZ\8eq\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \8f\83\90\88\89¼\91z\8aÖ\90\94\81A\92è\8b`\82Ì\82Ý\81i\94ñ\8eÀ\91\95\92ñ\8b\9f\81j\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \93à\95\94\83N\83\89\83X\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+\r
+\r
+};\r
+\r
+#endif //INC_CSocket\r
index 47d9920..99c0ca4 100644 (file)
-// \8b\9e
-
-#include "CThread.h"
-
-////////////////////////////////////////////////////////////////////////////////
-// \83R\83\93\83X\83g\83\89\83N\83^
-////////////////////////////////////////////////////////////////////////////////
-CThread::CThread()
-{
-       m_hThread = NULL;
-       m_doLoop  = false;
-       m_isExist = false;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \83f\83X\83g\83\89\83N\83^
-////////////////////////////////////////////////////////////////////////////////
-CThread::~CThread()
-{
-       CriticalSectionID begin = m_CriticalSectionList.begin();
-       CriticalSectionID end   = m_CriticalSectionList.end();
-       for(CriticalSectionID p = begin; p != end; p++){
-               DeleteCriticalSection(*p);
-       }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-// \83X\83\8c\83b\83h\83R\81[\83\8b\83o\83b\83N\97p
-////////////////////////////////////////////////////////////////////////////////
-unsigned int __stdcall CThread::procThread(void* in_pParameter)
-{
-       CThread* pClass = static_cast<CThread*>(in_pParameter);
-
-       while(pClass->m_isExist){
-               pClass->run();
-
-               if(!pClass->m_doLoop){
-                       break;
-               }
-       }
-
-       return 0;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \91\80\8dì\83\81\83\\83b\83h
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-// \83X\83\8c\83b\83h\82ð\8aJ\8en\82·\82é
-////////////////////////////////////////////////////////////////////////////////
-bool CThread::start(bool in_doLoop, UINT in_Flag)
-{
-       // \83f\83t\83H\83\8b\83g\82Å\82Í\82·\82®\82É\8aJ\8en\82·\82é
-       // CREATE_SUSPENDED\82ð\8ew\92è\82Å\83T\83X\83y\83\93\83h
-
-       UINT ThreadId;
-       m_hThread = reinterpret_cast<HANDLE>(_beginthreadex(0, 0, procThread, this, in_Flag, &ThreadId));
-       if(m_hThread == NULL){
-               return false;
-       }
-       m_doLoop = in_doLoop;
-       m_isExist = true;
-
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \83X\83\8c\83b\83h\82ð\8fI\97¹\82·\82é
-////////////////////////////////////////////////////////////////////////////////
-void CThread::stop()
-{
-       if(m_isExist){
-               m_isExist = false;
-
-               if(m_hThread != NULL){
-                       // \83X\83\8c\83b\83h\82Ì\8fI\97¹\82ð\91Ò\82Â
-                       ::WaitForSingleObject(m_hThread, INFINITE);
-                       // \83X\83\8c\83b\83h\83n\83\93\83h\83\8b\82ð\95Â\82\82é
-                       ::CloseHandle(m_hThread);
-                       m_hThread = NULL;
-               }
-       }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \83X\83\8c\83b\83h\82ð\88ê\8e\9e\92â\8e~\82·\82é
-////////////////////////////////////////////////////////////////////////////////
-UINT CThread::suspend()
-{
-       DWORD Status = ::SuspendThread(m_hThread);
-       if(Status == 0xFFFFFFFF){
-               return ::GetLastError();
-       }
-
-       return 0;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \83X\83\8c\83b\83h\82ð\8dÄ\83X\83^\81[\83g\82·\82é
-////////////////////////////////////////////////////////////////////////////////
-UINT CThread::resume()
-{
-       DWORD Status = ::ResumeThread(m_hThread);
-       if(Status == 0xFFFFFFFF){
-               return ::GetLastError();
-       }
-
-       return 0;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \83X\83\8c\83b\83h\83\8b\81[\83v
-////////////////////////////////////////////////////////////////////////////////
-void CThread::run()
-{
-       Sleep(100);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \83N\83\8a\83e\83B\83J\83\8b\83Z\83N\83V\83\87\83\93\90§\8cäID\82ð\8eæ\93¾\82·\82é
-////////////////////////////////////////////////////////////////////////////////
-const CriticalSectionID CThread::createCriticalSectionID()
-{
-       MyCriticalSection* temp = new MyCriticalSection;
-       InitializeCriticalSection(temp);
-       m_CriticalSectionList.push_front(temp);
-       return m_CriticalSectionList.begin();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \83N\83\8a\83e\83B\83J\83\8b\83Z\83N\83V\83\87\83\93\90§\8cäID\82ð\8aJ\95ú\82·\82é
-////////////////////////////////////////////////////////////////////////////////
-void CThread::deleteCriticalSectionID(const CriticalSectionID in_CriticalSectionID)
-{
-       DeleteCriticalSection(*in_CriticalSectionID);
-       m_CriticalSectionList.erase(in_CriticalSectionID);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \83N\83\8a\83e\83B\83J\83\8b\83Z\83N\83V\83\87\83\93\82É\93ü\82é
-////////////////////////////////////////////////////////////////////////////////
-void CThread::enterCriticalSectionID(const CriticalSectionID in_CriticalSectionID)
-{
-       EnterCriticalSection(*in_CriticalSectionID);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \83N\83\8a\83e\83B\83J\83\8b\83Z\83N\83V\83\87\83\93\82©\82ç\8fo\82é
-////////////////////////////////////////////////////////////////////////////////
-void CThread::leaveCriticalSectionID(const CriticalSectionID in_CriticalSectionID)
-{
-       LeaveCriticalSection(*in_CriticalSectionID);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \91®\90«\83\81\83\\83b\83h
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-// \83v\83\8d\83Z\83X\83v\83\89\83C\83I\83\8a\83e\83B\82Ì\90Ý\92è
-////////////////////////////////////////////////////////////////////////////////
-UINT CThread::setPriorityClass(DWORD in_PriorityClass)
-{
-       // \97D\90æ\8f\87\88Ê\83N\83\89\83X\82ª\8dÅ\8d\82\82Ì\8e\9e\82Í\88À\91S\82Ì\88×\81A\83G\83\89\81[\82Æ\82µ\82Ä\95Ô\82·\81B
-       if(in_PriorityClass == REALTIME_PRIORITY_CLASS){
-               return -1;
-       }
-
-       BOOL Status = ::SetPriorityClass(m_hThread, in_PriorityClass);
-       if(!Status){
-               return ::GetLastError();
-       }
-
-       return 0;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \83X\83\8c\83b\83h\82Ì\97D\90æ\93x\82ð\90Ý\92è\82·\82é
-////////////////////////////////////////////////////////////////////////////////
-UINT CThread::setPriority(int in_Priority)
-{
-       BOOL Status = ::SetThreadPriority(m_hThread, in_Priority);
-       if(!Status){
-               return ::GetLastError();
-       }
-
-       return 0;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \83X\83\8c\83b\83h\82Ì\97D\90æ\93x\82ð\97D\90æ\93x\82ð\8dÅ\92á( = 1)\82É\82·\82é
-////////////////////////////////////////////////////////////////////////////////
-UINT CThread::setPriorityMinimum()
-{
-       BOOL Status = ::SetThreadPriority(m_hThread, THREAD_PRIORITY_IDLE);
-       if(!Status){
-               return ::GetLastError();
-       }
-
-       return 0;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \83X\83\8c\83b\83h\82Ì\97D\90æ\93x\82ð\97D\90æ\93x\82ð\8dÅ\91å( = 15)\82É\82·\82é
-////////////////////////////////////////////////////////////////////////////////
-UINT CThread::setPriorityMaxisim()
-{
-       BOOL Status = ::SetThreadPriority(m_hThread, THREAD_PRIORITY_TIME_CRITICAL);
-       if(!Status){
-               return ::GetLastError();
-       }
-
-       return 0;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \8fó\91Ô
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-// \83X\83\8c\83b\83h\82ª\91\8dÝ\82·\82é\82©\92²\82×\82é
-////////////////////////////////////////////////////////////////////////////////
-bool CThread::isExist()
-{
-       return m_isExist;
-}
+// \8b\9e\r
+\r
+#include "CThread.h"\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83R\83\93\83X\83g\83\89\83N\83^\r
+////////////////////////////////////////////////////////////////////////////////\r
+CThread::CThread()\r
+{\r
+       m_hThread = NULL;\r
+       m_doLoop  = false;\r
+       m_isExist = false;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83f\83X\83g\83\89\83N\83^\r
+////////////////////////////////////////////////////////////////////////////////\r
+CThread::~CThread()\r
+{\r
+       CriticalSectionID begin = m_CriticalSectionList.begin();\r
+       CriticalSectionID end   = m_CriticalSectionList.end();\r
+       for(CriticalSectionID p = begin; p != end; p++){\r
+               DeleteCriticalSection(*p);\r
+       }\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94\r
+////////////////////////////////////////////////////////////////////////////////\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83X\83\8c\83b\83h\83R\81[\83\8b\83o\83b\83N\97p\r
+////////////////////////////////////////////////////////////////////////////////\r
+unsigned int __stdcall CThread::procThread(void* in_pParameter)\r
+{\r
+       CThread* pClass = static_cast<CThread*>(in_pParameter);\r
+\r
+       while(pClass->m_isExist){\r
+               pClass->run();\r
+\r
+               if(!pClass->m_doLoop){\r
+                       break;\r
+               }\r
+       }\r
+\r
+       return 0;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \91\80\8dì\83\81\83\\83b\83h\r
+////////////////////////////////////////////////////////////////////////////////\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83X\83\8c\83b\83h\82ð\8aJ\8en\82·\82é\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CThread::start(bool in_doLoop, UINT in_Flag)\r
+{\r
+       // \83f\83t\83H\83\8b\83g\82Å\82Í\82·\82®\82É\8aJ\8en\82·\82é\r
+       // CREATE_SUSPENDED\82ð\8ew\92è\82Å\83T\83X\83y\83\93\83h\r
+\r
+       UINT ThreadId;\r
+       m_hThread = reinterpret_cast<HANDLE>(_beginthreadex(0, 0, procThread, this, in_Flag, &ThreadId));\r
+       if(m_hThread == NULL){\r
+               return false;\r
+       }\r
+       m_doLoop = in_doLoop;\r
+       m_isExist = true;\r
+\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83X\83\8c\83b\83h\82ð\8fI\97¹\82·\82é\r
+////////////////////////////////////////////////////////////////////////////////\r
+void CThread::stop()\r
+{\r
+       if(m_isExist){\r
+               m_isExist = false;\r
+\r
+               if(m_hThread != NULL){\r
+                       // \83X\83\8c\83b\83h\82Ì\8fI\97¹\82ð\91Ò\82Â\r
+                       ::WaitForSingleObject(m_hThread, INFINITE);\r
+                       // \83X\83\8c\83b\83h\83n\83\93\83h\83\8b\82ð\95Â\82\82é\r
+                       ::CloseHandle(m_hThread);\r
+                       m_hThread = NULL;\r
+               }\r
+       }\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83X\83\8c\83b\83h\82ð\88ê\8e\9e\92â\8e~\82·\82é\r
+////////////////////////////////////////////////////////////////////////////////\r
+UINT CThread::suspend()\r
+{\r
+       DWORD Status = ::SuspendThread(m_hThread);\r
+       if(Status == 0xFFFFFFFF){\r
+               return ::GetLastError();\r
+       }\r
+\r
+       return 0;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83X\83\8c\83b\83h\82ð\8dÄ\83X\83^\81[\83g\82·\82é\r
+////////////////////////////////////////////////////////////////////////////////\r
+UINT CThread::resume()\r
+{\r
+       DWORD Status = ::ResumeThread(m_hThread);\r
+       if(Status == 0xFFFFFFFF){\r
+               return ::GetLastError();\r
+       }\r
+\r
+       return 0;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83X\83\8c\83b\83h\83\8b\81[\83v\r
+////////////////////////////////////////////////////////////////////////////////\r
+void CThread::run()\r
+{\r
+       Sleep(100);\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83N\83\8a\83e\83B\83J\83\8b\83Z\83N\83V\83\87\83\93\90§\8cäID\82ð\8eæ\93¾\82·\82é\r
+////////////////////////////////////////////////////////////////////////////////\r
+const CriticalSectionID CThread::createCriticalSectionID()\r
+{\r
+       MyCriticalSection* temp = new MyCriticalSection;\r
+       InitializeCriticalSection(temp);\r
+       m_CriticalSectionList.push_front(temp);\r
+       return m_CriticalSectionList.begin();\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83N\83\8a\83e\83B\83J\83\8b\83Z\83N\83V\83\87\83\93\90§\8cäID\82ð\8aJ\95ú\82·\82é\r
+////////////////////////////////////////////////////////////////////////////////\r
+void CThread::deleteCriticalSectionID(const CriticalSectionID in_CriticalSectionID)\r
+{\r
+       DeleteCriticalSection(*in_CriticalSectionID);\r
+       m_CriticalSectionList.erase(in_CriticalSectionID);\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83N\83\8a\83e\83B\83J\83\8b\83Z\83N\83V\83\87\83\93\82É\93ü\82é\r
+////////////////////////////////////////////////////////////////////////////////\r
+void CThread::enterCriticalSectionID(const CriticalSectionID in_CriticalSectionID)\r
+{\r
+       EnterCriticalSection(*in_CriticalSectionID);\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83N\83\8a\83e\83B\83J\83\8b\83Z\83N\83V\83\87\83\93\82©\82ç\8fo\82é\r
+////////////////////////////////////////////////////////////////////////////////\r
+void CThread::leaveCriticalSectionID(const CriticalSectionID in_CriticalSectionID)\r
+{\r
+       LeaveCriticalSection(*in_CriticalSectionID);\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \91®\90«\83\81\83\\83b\83h\r
+////////////////////////////////////////////////////////////////////////////////\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83v\83\8d\83Z\83X\83v\83\89\83C\83I\83\8a\83e\83B\82Ì\90Ý\92è\r
+////////////////////////////////////////////////////////////////////////////////\r
+UINT CThread::setPriorityClass(DWORD in_PriorityClass)\r
+{\r
+       // \97D\90æ\8f\87\88Ê\83N\83\89\83X\82ª\8dÅ\8d\82\82Ì\8e\9e\82Í\88À\91S\82Ì\88×\81A\83G\83\89\81[\82Æ\82µ\82Ä\95Ô\82·\81B\r
+       if(in_PriorityClass == REALTIME_PRIORITY_CLASS){\r
+               return -1;\r
+       }\r
+\r
+       BOOL Status = ::SetPriorityClass(m_hThread, in_PriorityClass);\r
+       if(!Status){\r
+               return ::GetLastError();\r
+       }\r
+\r
+       return 0;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83X\83\8c\83b\83h\82Ì\97D\90æ\93x\82ð\90Ý\92è\82·\82é\r
+////////////////////////////////////////////////////////////////////////////////\r
+UINT CThread::setPriority(int in_Priority)\r
+{\r
+       BOOL Status = ::SetThreadPriority(m_hThread, in_Priority);\r
+       if(!Status){\r
+               return ::GetLastError();\r
+       }\r
+\r
+       return 0;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83X\83\8c\83b\83h\82Ì\97D\90æ\93x\82ð\97D\90æ\93x\82ð\8dÅ\92á( = 1)\82É\82·\82é\r
+////////////////////////////////////////////////////////////////////////////////\r
+UINT CThread::setPriorityMinimum()\r
+{\r
+       BOOL Status = ::SetThreadPriority(m_hThread, THREAD_PRIORITY_IDLE);\r
+       if(!Status){\r
+               return ::GetLastError();\r
+       }\r
+\r
+       return 0;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83X\83\8c\83b\83h\82Ì\97D\90æ\93x\82ð\97D\90æ\93x\82ð\8dÅ\91å( = 15)\82É\82·\82é\r
+////////////////////////////////////////////////////////////////////////////////\r
+UINT CThread::setPriorityMaxisim()\r
+{\r
+       BOOL Status = ::SetThreadPriority(m_hThread, THREAD_PRIORITY_TIME_CRITICAL);\r
+       if(!Status){\r
+               return ::GetLastError();\r
+       }\r
+\r
+       return 0;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \8fó\91Ô\r
+////////////////////////////////////////////////////////////////////////////////\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83X\83\8c\83b\83h\82ª\91\8dÝ\82·\82é\82©\92²\82×\82é\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CThread::isExist()\r
+{\r
+       return m_isExist;\r
+}\r
index 1740bd7..a97b4b1 100644 (file)
-// \8b\9e
-
-#ifndef INC_CThread
-#define INC_CThread
-
-#include <windows.h>
-#include <process.h>
-#include <list>
-
-typedef CRITICAL_SECTION MyCriticalSection;
-typedef std::list<MyCriticalSection*> CriticalSectionList;
-typedef CriticalSectionList::iterator CriticalSectionID;
-
-////////////////////////////////////////////////////////////////////////////////
-// CThread
-// Windows\97p\83X\83\8c\83b\83h\83N\83\89\83X
-////////////////////////////////////////////////////////////////////////////////
-class CThread
-{
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83\81\83\93\83o\95Ï\90\94
-       ////////////////////////////////////////////////////////////////////////////////
-protected:
-       // Windows\97p\83X\83\8c\83b\83h\90§\8cä\97p
-       HANDLE m_hThread;
-       // \83X\83\8c\83b\83h\8aÖ\90\94\83\8b\81[\83v\8aÇ\97\9d\97p
-       bool m_doLoop;
-       // \83X\83\8c\83b\83h\91\8dÝ\8aÇ\97\9d\97p
-       bool m_isExist;
-
-private:
-       // \83N\83\8a\83e\83B\83J\83\8b\83Z\83N\83V\83\87\83\93\90§\8cä\97p
-       CriticalSectionList m_CriticalSectionList;
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83R\83\93\83X\83g\83\89\83N\83^
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       CThread();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83f\83X\83g\83\89\83N\83^
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       virtual ~CThread();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94
-       ////////////////////////////////////////////////////////////////////////////////
-protected:
-       static unsigned int __stdcall procThread(void* in_pParameter);
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \91\80\8dì\83\81\83\\83b\83h
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       // \83X\83^\81[\83g(DoLoop: true - \8cJ\82è\95Ô\82·, false - \88ê\89ñ\82Ì\82Ý, Flag: \83X\83\8c\83b\83h\82Ì\90Ý\92è)
-       virtual bool start(bool in_doLoop = false, UINT in_Flag = 0);
-       // \83X\83g\83b\83v
-       virtual void stop();
-       // \88ê\8e\9e\92â\8e~
-       virtual UINT suspend();
-       // \83X\83\8c\83b\83h\8dÄ\83X\83^\81[\83g
-       virtual UINT resume();
-protected:
-       // \83X\83\8c\83b\83h\83\8b\81[\83v
-       virtual void run();
-
-public:
-       // \83N\83\8a\83e\83B\83J\83\8b\83Z\83N\83V\83\87\83\93\90§\8cäID\82ð\8eæ\93¾\82·\82é
-       const CriticalSectionID createCriticalSectionID();
-       // \83N\83\8a\83e\83B\83J\83\8b\83Z\83N\83V\83\87\83\93\90§\8cäID\82ð\8aJ\95ú\82·\82é
-       void deleteCriticalSectionID(const CriticalSectionID in_CriticalSectionID);
-       // \83N\83\8a\83e\83B\83J\83\8b\83Z\83N\83V\83\87\83\93\82É\93ü\82é
-       void enterCriticalSectionID(const CriticalSectionID in_CriticalSectionID);
-       // \83N\83\8a\83e\83B\83J\83\8b\83Z\83N\83V\83\87\83\93\82©\82ç\8fo\82é
-       void leaveCriticalSectionID(const CriticalSectionID in_CriticalSectionID);
-
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \91®\90«\83\81\83\\83b\83h
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       // \83v\83\8d\83Z\83X\83v\83\89\83C\83I\83\8a\83e\83B\82Ì\90Ý\92è
-       virtual UINT setPriorityClass(DWORD in_PriorityClass);
-       // \97D\90æ\93x\82Ì\90Ý\92è
-       virtual UINT setPriority(int in_Priority);
-       // \97D\90æ\93x\82ð\8dÅ\92á\82É\82·\82é
-       virtual UINT setPriorityMinimum();
-       // \97D\90æ\93x\82ð\8dÅ\91å\82É\82·\82é
-       virtual UINT setPriorityMaxisim();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83C\83e\83\8c\81[\83V\83\87\83\93
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \8fó\91Ô
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       // \83X\83\8c\83b\83h\82ª\91\8dÝ\82·\82é\82©\92²\82×\82é
-       virtual bool isExist();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \89\89\8eZ\8eq
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \8f\83\90\88\89¼\91z\8aÖ\90\94\81A\92è\8b`\82Ì\82Ý\81i\94ñ\8eÀ\91\95\92ñ\8b\9f\81j
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \93à\95\94\83N\83\89\83X
-       ////////////////////////////////////////////////////////////////////////////////
-};
-
-#endif //INC_CThread
+// \8b\9e\r
+\r
+#ifndef INC_CThread\r
+#define INC_CThread\r
+\r
+#include <windows.h>\r
+#include <process.h>\r
+#include <list>\r
+\r
+typedef CRITICAL_SECTION MyCriticalSection;\r
+typedef std::list<MyCriticalSection*> CriticalSectionList;\r
+typedef CriticalSectionList::iterator CriticalSectionID;\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// CThread\r
+// Windows\97p\83X\83\8c\83b\83h\83N\83\89\83X\r
+////////////////////////////////////////////////////////////////////////////////\r
+class CThread\r
+{\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83\81\83\93\83o\95Ï\90\94\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+protected:\r
+       // Windows\97p\83X\83\8c\83b\83h\90§\8cä\97p\r
+       HANDLE m_hThread;\r
+       // \83X\83\8c\83b\83h\8aÖ\90\94\83\8b\81[\83v\8aÇ\97\9d\97p\r
+       bool m_doLoop;\r
+       // \83X\83\8c\83b\83h\91\8dÝ\8aÇ\97\9d\97p\r
+       bool m_isExist;\r
+\r
+private:\r
+       // \83N\83\8a\83e\83B\83J\83\8b\83Z\83N\83V\83\87\83\93\90§\8cä\97p\r
+       CriticalSectionList m_CriticalSectionList;\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83R\83\93\83X\83g\83\89\83N\83^\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       CThread();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83f\83X\83g\83\89\83N\83^\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       virtual ~CThread();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+protected:\r
+       static unsigned int __stdcall procThread(void* in_pParameter);\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \91\80\8dì\83\81\83\\83b\83h\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       // \83X\83^\81[\83g(DoLoop: true - \8cJ\82è\95Ô\82·, false - \88ê\89ñ\82Ì\82Ý, Flag: \83X\83\8c\83b\83h\82Ì\90Ý\92è)\r
+       virtual bool start(bool in_doLoop = false, UINT in_Flag = 0);\r
+       // \83X\83g\83b\83v\r
+       virtual void stop();\r
+       // \88ê\8e\9e\92â\8e~\r
+       virtual UINT suspend();\r
+       // \83X\83\8c\83b\83h\8dÄ\83X\83^\81[\83g\r
+       virtual UINT resume();\r
+protected:\r
+       // \83X\83\8c\83b\83h\83\8b\81[\83v\r
+       virtual void run();\r
+\r
+public:\r
+       // \83N\83\8a\83e\83B\83J\83\8b\83Z\83N\83V\83\87\83\93\90§\8cäID\82ð\8eæ\93¾\82·\82é\r
+       const CriticalSectionID createCriticalSectionID();\r
+       // \83N\83\8a\83e\83B\83J\83\8b\83Z\83N\83V\83\87\83\93\90§\8cäID\82ð\8aJ\95ú\82·\82é\r
+       void deleteCriticalSectionID(const CriticalSectionID in_CriticalSectionID);\r
+       // \83N\83\8a\83e\83B\83J\83\8b\83Z\83N\83V\83\87\83\93\82É\93ü\82é\r
+       void enterCriticalSectionID(const CriticalSectionID in_CriticalSectionID);\r
+       // \83N\83\8a\83e\83B\83J\83\8b\83Z\83N\83V\83\87\83\93\82©\82ç\8fo\82é\r
+       void leaveCriticalSectionID(const CriticalSectionID in_CriticalSectionID);\r
+\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \91®\90«\83\81\83\\83b\83h\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       // \83v\83\8d\83Z\83X\83v\83\89\83C\83I\83\8a\83e\83B\82Ì\90Ý\92è\r
+       virtual UINT setPriorityClass(DWORD in_PriorityClass);\r
+       // \97D\90æ\93x\82Ì\90Ý\92è\r
+       virtual UINT setPriority(int in_Priority);\r
+       // \97D\90æ\93x\82ð\8dÅ\92á\82É\82·\82é\r
+       virtual UINT setPriorityMinimum();\r
+       // \97D\90æ\93x\82ð\8dÅ\91å\82É\82·\82é\r
+       virtual UINT setPriorityMaxisim();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83C\83e\83\8c\81[\83V\83\87\83\93\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \8fó\91Ô\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       // \83X\83\8c\83b\83h\82ª\91\8dÝ\82·\82é\82©\92²\82×\82é\r
+       virtual bool isExist();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \89\89\8eZ\8eq\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \8f\83\90\88\89¼\91z\8aÖ\90\94\81A\92è\8b`\82Ì\82Ý\81i\94ñ\8eÀ\91\95\92ñ\8b\9f\81j\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \93à\95\94\83N\83\89\83X\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+};\r
+\r
+#endif //INC_CThread\r
index 5a2c10c..7f49f6d 100644 (file)
@@ -1,92 +1,92 @@
-// \8b\9e
-
-/*
-#include "CWaveData.h"
-
-#include <windows.h>
-#include <tchar.h>
-
-////////////////////////////////////////////////////////////////////////////////
-// \83R\83\93\83X\83g\83\89\83N\83^
-////////////////////////////////////////////////////////////////////////////////
-CWaveData::CWaveData()
-{
-       // Wave\83t\83H\81[\83}\83b\83g
-       m_WaveFormat.wFormatTag      = WAVE_FORMAT_PCM;
-       m_WaveFormat.nChannels       = 1;
-       m_WaveFormat.nSamplesPerSec  = 22050;
-       m_WaveFormat.wBitsPerSample  = 8;
-       m_WaveFormat.nBlockAlign     = m_WaveFormat.wBitsPerSample / 8 * m_WaveFormat.nChannels;
-       m_WaveFormat.nAvgBytesPerSec = m_WaveFormat.nSamplesPerSec * m_WaveFormat.nBlockAlign;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \83f\83X\83g\83\89\83N\83^
-////////////////////////////////////////////////////////////////////////////////
-CWaveData::~CWaveData()
-{
-       freeBuffer();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \8f\89\8aú\89»
-////////////////////////////////////////////////////////////////////////////////
-void CWaveData::initialize()
-{
-       // \8c»\8fó\83t\83H\81[\83}\83b\83g\82Í\8c\88\82ß\82¤\82¿
-       m_WaveFormat.wFormatTag      = WAVE_FORMAT_PCM;
-       m_WaveFormat.nChannels       = 1;
-       m_WaveFormat.nSamplesPerSec  = 22050;
-       m_WaveFormat.wBitsPerSample  = 8;
-       m_WaveFormat.nBlockAlign     = m_WaveFormat.wBitsPerSample / 8 * m_WaveFormat.nChannels;
-       m_WaveFormat.nAvgBytesPerSec = m_WaveFormat.nSamplesPerSec * m_WaveFormat.nBlockAlign;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \83o\83b\83t\83@\82ð\8am\95Û
-////////////////////////////////////////////////////////////////////////////////
-bool CWaveData::allocBuffer(int in_BufferNumber, DWORD in_RecorMilliSecond)
-{
-       if(in_BufferNumber < 1 || in_RecorMilliSecond == 0){
-               return false;
-       }
-
-       if(m_WaveBuffers.empty()){
-               // free
-               if(!freeBuffer()){
-                       return false;
-               }
-       }
-
-       for(int i = 0; i < in_BufferNumber; i++){
-               StructWaveBuffer tempWaveBuffer;
-               tempWaveBuffer.m_RecorMilliSecond = in_RecorMilliSecond;
-               tempWaveBuffer.m_BufferSize   = m_WaveFormat.nAvgBytesPerSec * in_RecorMilliSecond / 1000;
-               tempWaveBuffer.m_pWaveBuffer = new char[tempWaveBuffer.m_BufferSize];
-
-               m_WaveBuffers.push_back(tempWaveBuffer);
-       }
-
-       // \93Ç\82Ý\8eæ\82è\83o\83b\83t\83@\82Æ\8f\91\82«\8d\9e\82Ý\83o\83b\83t\83@\82ð\8ew\92è\82µ\82Ä\82¨\82­
-       m_ReadOfWaveBuffers = m_WaveBuffers.begin();
-       m_WriteOfWaveBuffers = m_WaveBuffers.begin();
-
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \83o\83b\83t\83@\82ð\89ð\95ú
-////////////////////////////////////////////////////////////////////////////////
-bool CWaveData::freeBuffer()
-{
-       if(!m_WaveBuffers.empty()){
-               WaveBufferTable::iterator tempIterator = m_WaveBuffers.begin();
-               while(tempIterator != m_WaveBuffers.end()){
-                       delete tempIterator->m_pWaveBuffer;
-                       tempIterator++;
-               }
-       }
-       return true;
-}
-*/
-
+// \8b\9e\r
+\r
+/*\r
+#include "CWaveData.h"\r
+\r
+#include <windows.h>\r
+#include <tchar.h>\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83R\83\93\83X\83g\83\89\83N\83^\r
+////////////////////////////////////////////////////////////////////////////////\r
+CWaveData::CWaveData()\r
+{\r
+       // Wave\83t\83H\81[\83}\83b\83g\r
+       m_WaveFormat.wFormatTag      = WAVE_FORMAT_PCM;\r
+       m_WaveFormat.nChannels       = 1;\r
+       m_WaveFormat.nSamplesPerSec  = 22050;\r
+       m_WaveFormat.wBitsPerSample  = 8;\r
+       m_WaveFormat.nBlockAlign     = m_WaveFormat.wBitsPerSample / 8 * m_WaveFormat.nChannels;\r
+       m_WaveFormat.nAvgBytesPerSec = m_WaveFormat.nSamplesPerSec * m_WaveFormat.nBlockAlign;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83f\83X\83g\83\89\83N\83^\r
+////////////////////////////////////////////////////////////////////////////////\r
+CWaveData::~CWaveData()\r
+{\r
+       freeBuffer();\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \8f\89\8aú\89»\r
+////////////////////////////////////////////////////////////////////////////////\r
+void CWaveData::initialize()\r
+{\r
+       // \8c»\8fó\83t\83H\81[\83}\83b\83g\82Í\8c\88\82ß\82¤\82¿\r
+       m_WaveFormat.wFormatTag      = WAVE_FORMAT_PCM;\r
+       m_WaveFormat.nChannels       = 1;\r
+       m_WaveFormat.nSamplesPerSec  = 22050;\r
+       m_WaveFormat.wBitsPerSample  = 8;\r
+       m_WaveFormat.nBlockAlign     = m_WaveFormat.wBitsPerSample / 8 * m_WaveFormat.nChannels;\r
+       m_WaveFormat.nAvgBytesPerSec = m_WaveFormat.nSamplesPerSec * m_WaveFormat.nBlockAlign;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83o\83b\83t\83@\82ð\8am\95Û\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CWaveData::allocBuffer(int in_BufferNumber, DWORD in_RecorMilliSecond)\r
+{\r
+       if(in_BufferNumber < 1 || in_RecorMilliSecond == 0){\r
+               return false;\r
+       }\r
+\r
+       if(m_WaveBuffers.empty()){\r
+               // free\r
+               if(!freeBuffer()){\r
+                       return false;\r
+               }\r
+       }\r
+\r
+       for(int i = 0; i < in_BufferNumber; i++){\r
+               StructWaveBuffer tempWaveBuffer;\r
+               tempWaveBuffer.m_RecorMilliSecond = in_RecorMilliSecond;\r
+               tempWaveBuffer.m_BufferSize   = m_WaveFormat.nAvgBytesPerSec * in_RecorMilliSecond / 1000;\r
+               tempWaveBuffer.m_pWaveBuffer = new char[tempWaveBuffer.m_BufferSize];\r
+\r
+               m_WaveBuffers.push_back(tempWaveBuffer);\r
+       }\r
+\r
+       // \93Ç\82Ý\8eæ\82è\83o\83b\83t\83@\82Æ\8f\91\82«\8d\9e\82Ý\83o\83b\83t\83@\82ð\8ew\92è\82µ\82Ä\82¨\82­\r
+       m_ReadOfWaveBuffers = m_WaveBuffers.begin();\r
+       m_WriteOfWaveBuffers = m_WaveBuffers.begin();\r
+\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83o\83b\83t\83@\82ð\89ð\95ú\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CWaveData::freeBuffer()\r
+{\r
+       if(!m_WaveBuffers.empty()){\r
+               WaveBufferTable::iterator tempIterator = m_WaveBuffers.begin();\r
+               while(tempIterator != m_WaveBuffers.end()){\r
+                       delete tempIterator->m_pWaveBuffer;\r
+                       tempIterator++;\r
+               }\r
+       }\r
+       return true;\r
+}\r
+*/\r
+\r
index 36f8ca9..a8fd384 100644 (file)
-// \8b\9e
-#ifndef INC_CWaveData
-#define INC_CWaveData
-
-
-#include "CRingBuffer.h"
-#include <Windows.h>
-
-
-// \83C\83\93\83N\83\8b\81[\83h\82Í\95K\82¸\95K\97v\82È\95¨\82¾\82¯
-// \93à\95\94\82Å\97\98\97p\82·\82é\82¾\82¯\82Ì\95¨\82Í\83\\81[\83X\82É\8bL\8fq
-
-// \8aÖ\90\94\96¼\82Í\83\8d\81[\83\8f\83L\83\83\83\81\83\8b\83P\81[\83X\82Æ\82·\82é
-
-
-// wave buffer struct
-struct StructWaveBuffer
-{
-       // \83o\83b\83t\83@\82Ö\82Ì\83|\83C\83\93\83^
-       char* m_pWaveBuffer;
-       // \98^\89¹\8e\9e\8aÔ [\83~\83\8a\95b]
-       DWORD m_RecorMilliSecond;
-       // \83o\83b\83t\83@\83T\83C\83Y [byte]
-       DWORD m_BufferSize;
-};
-
-
-////////////////////////////////////////////////////////////////////////////////
-// CWaveData
-// Wave\83f\81[\83^\82ð\88µ\82¤\83N\83\89\83X
-// \83o\83b\83t\83@\82Ì\8aÇ\97\9d\81i\8am\95Û\82Æ\89ð\95ú\81j\82ð\8ds\82¤
-// \83L\83\85\81[\82ð\97p\82¢\82Ä\83o\83b\83t\83@\8aÇ\97\9d\82ð\8ds\82¤
-////////////////////////////////////////////////////////////////////////////////
-class CWaveData : public CRingBuffer<StructWaveBuffer>
-{
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83\81\83\93\83o\95Ï\90\94
-       ////////////////////////////////////////////////////////////////////////////////
-private:
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83R\83\93\83X\83g\83\89\83N\83^
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       CWaveData(){}
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83f\83X\83g\83\89\83N\83^
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       ~CWaveData(){}
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \91\80\8dì\83\81\83\\83b\83h
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       // \83o\83b\83t\83@\82ð\8am\95Û
-       bool allocate(int in_BufferNumber, DWORD in_RecorMilliSecond, DWORD in_BufferSize)
-       {
-               if(!CRingBuffer::allocate(in_BufferNumber) || in_BufferSize == 0){
-                       return false;
-               }
-
-               for(int i = 0; i < in_BufferNumber; i++){
-                       StructWaveBuffer tempWaveBuffer;
-                       tempWaveBuffer.m_RecorMilliSecond = in_RecorMilliSecond;
-                       tempWaveBuffer.m_BufferSize       = in_BufferSize;
-                       tempWaveBuffer.m_pWaveBuffer      = new char[tempWaveBuffer.m_BufferSize];
-                       *at(i) = tempWaveBuffer;
-               }
-
-               return true;
-       }
-
-       void clear()
-       {
-               for(size_t i = 0; i < size(); i++){
-                       StructWaveBuffer* tempWaveBuffer = at(i);
-                       delete tempWaveBuffer->m_pWaveBuffer;
-               }
-               CRingBuffer::clear();
-       }
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \91®\90«\83\81\83\\83b\83h
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83C\83e\83\8c\81[\83V\83\87\83\93
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \8fó\91Ô
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \89\89\8eZ\8eq
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \8f\83\90\88\89¼\91z\8aÖ\90\94\81A\92è\8b`\82Ì\82Ý\81i\94ñ\8eÀ\91\95\92ñ\8b\9f\81j
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \93à\95\94\83N\83\89\83X
-       ////////////////////////////////////////////////////////////////////////////////
-
-
-};
-
-
-#endif //INC_CWaveData
+// \8b\9e\r
+#ifndef INC_CWaveData\r
+#define INC_CWaveData\r
+\r
+\r
+#include "CRingBuffer.h"\r
+#include <Windows.h>\r
+\r
+\r
+// \83C\83\93\83N\83\8b\81[\83h\82Í\95K\82¸\95K\97v\82È\95¨\82¾\82¯\r
+// \93à\95\94\82Å\97\98\97p\82·\82é\82¾\82¯\82Ì\95¨\82Í\83\\81[\83X\82É\8bL\8fq\r
+\r
+// \8aÖ\90\94\96¼\82Í\83\8d\81[\83\8f\83L\83\83\83\81\83\8b\83P\81[\83X\82Æ\82·\82é\r
+\r
+\r
+// wave buffer struct\r
+struct StructWaveBuffer\r
+{\r
+       // \83o\83b\83t\83@\82Ö\82Ì\83|\83C\83\93\83^\r
+       char* m_pWaveBuffer;\r
+       // \98^\89¹\8e\9e\8aÔ [\83~\83\8a\95b]\r
+       DWORD m_RecorMilliSecond;\r
+       // \83o\83b\83t\83@\83T\83C\83Y [byte]\r
+       DWORD m_BufferSize;\r
+};\r
+\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// CWaveData\r
+// Wave\83f\81[\83^\82ð\88µ\82¤\83N\83\89\83X\r
+// \83o\83b\83t\83@\82Ì\8aÇ\97\9d\81i\8am\95Û\82Æ\89ð\95ú\81j\82ð\8ds\82¤\r
+// \83L\83\85\81[\82ð\97p\82¢\82Ä\83o\83b\83t\83@\8aÇ\97\9d\82ð\8ds\82¤\r
+////////////////////////////////////////////////////////////////////////////////\r
+class CWaveData : public CRingBuffer<StructWaveBuffer>\r
+{\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83\81\83\93\83o\95Ï\90\94\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+private:\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83R\83\93\83X\83g\83\89\83N\83^\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       CWaveData(){}\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83f\83X\83g\83\89\83N\83^\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       ~CWaveData(){}\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \91\80\8dì\83\81\83\\83b\83h\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       // \83o\83b\83t\83@\82ð\8am\95Û\r
+       bool allocate(int in_BufferNumber, DWORD in_RecorMilliSecond, DWORD in_BufferSize)\r
+       {\r
+               if(!CRingBuffer::allocate(in_BufferNumber) || in_BufferSize == 0){\r
+                       return false;\r
+               }\r
+\r
+               for(int i = 0; i < in_BufferNumber; i++){\r
+                       StructWaveBuffer tempWaveBuffer;\r
+                       tempWaveBuffer.m_RecorMilliSecond = in_RecorMilliSecond;\r
+                       tempWaveBuffer.m_BufferSize       = in_BufferSize;\r
+                       tempWaveBuffer.m_pWaveBuffer      = new char[tempWaveBuffer.m_BufferSize];\r
+                       *at(i) = tempWaveBuffer;\r
+               }\r
+\r
+               return true;\r
+       }\r
+\r
+       void clear()\r
+       {\r
+               for(size_t i = 0; i < size(); i++){\r
+                       StructWaveBuffer* tempWaveBuffer = at(i);\r
+                       delete tempWaveBuffer->m_pWaveBuffer;\r
+               }\r
+               CRingBuffer::clear();\r
+       }\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \91®\90«\83\81\83\\83b\83h\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83C\83e\83\8c\81[\83V\83\87\83\93\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \8fó\91Ô\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \89\89\8eZ\8eq\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \8f\83\90\88\89¼\91z\8aÖ\90\94\81A\92è\8b`\82Ì\82Ý\81i\94ñ\8eÀ\91\95\92ñ\8b\9f\81j\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \93à\95\94\83N\83\89\83X\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+\r
+\r
+};\r
+\r
+\r
+#endif //INC_CWaveData\r
index 1a0d87f..789e511 100644 (file)
@@ -1,66 +1,66 @@
-// \8b\9e
-
-#ifndef INC_DATA
-#define INC_DATA
-
-static const int MAX_AVATAR_NAME_LENGTH = 32;
-static const int MAX_COMMUNICATION_DATA_LENGTH = 120;
-
-#include "CWaveData.h"
-
-// \83A\83o\83^\81[\82Ì\8fî\95ñ
-struct AvatarInformation
-{
-       // \83L\83\83\83\89\83N\83^\81[\96¼
-       char m_Name[MAX_AVATAR_NAME_LENGTH];
-       // \8dÀ\95W
-       double m_Position[3];
-       // \95û\8cü
-       double m_Direction[3];
-       // \83T\83C\83Y
-       double m_Radias;
-       // \89¹\90º\83f\81[\83^
-       CWaveData m_Voice;
-       // \88³\8fk\89¹\90º\83f\81[\83^
-       char m_Stream[3000];
-       int m_Length;
-};
-
-struct VoiceData{
-       char m_Stream[100];
-       short m_Length;
-       char m_isEnd;
-};
-
-// \88ê\94Ê\92Ê\90M\83f\81[\83^
-struct CommunicationData{
-       // \83f\81[\83^\82Ì\8eí\97Þ
-       char m_DataType;
-       // \83f\81[\83^
-       union{
-               struct{
-                       char m_Name[MAX_AVATAR_NAME_LENGTH];
-               } m_LoginData;
-               struct{
-                       // \97L\8cø\82©\82Ç\82¤\82©
-                       char m_Enable;
-                       // \96¼\91O
-                       char m_Name[MAX_AVATAR_NAME_LENGTH];
-                       // \8dÀ\95W
-                       double m_Position[3];
-                       // \95û\8cü
-                       double m_Direction[3];
-                       // \83T\83C\83Y
-                       double m_Radias;
-               } m_AvatarData;
-               struct{
-                       char m_CommandType;
-               } m_ActionCommand;
-               // \89¹\90º
-               VoiceData m_Voice;
-               // \83f\81[\83^\83T\83C\83Y\92²\90®
-               char m_Dummy[MAX_COMMUNICATION_DATA_LENGTH - 1];
-       } m_Data;
-};
-
-#endif // INC_DATA
+// \8b\9e\r
+\r
+#ifndef INC_DATA\r
+#define INC_DATA\r
+\r
+static const int MAX_AVATAR_NAME_LENGTH = 32;\r
+static const int MAX_COMMUNICATION_DATA_LENGTH = 120;\r
+\r
+#include "CWaveData.h"\r
+\r
+// \83A\83o\83^\81[\82Ì\8fî\95ñ\r
+struct AvatarInformation\r
+{\r
+       // \83L\83\83\83\89\83N\83^\81[\96¼\r
+       char m_Name[MAX_AVATAR_NAME_LENGTH];\r
+       // \8dÀ\95W\r
+       double m_Position[3];\r
+       // \95û\8cü\r
+       double m_Direction[3];\r
+       // \83T\83C\83Y\r
+       double m_Radias;\r
+       // \89¹\90º\83f\81[\83^\r
+       CWaveData m_Voice;\r
+       // \88³\8fk\89¹\90º\83f\81[\83^\r
+       char m_Stream[3000];\r
+       int m_Length;\r
+};\r
+\r
+struct VoiceData{\r
+       char m_Stream[100];\r
+       short m_Length;\r
+       char m_isEnd;\r
+};\r
+\r
+// \88ê\94Ê\92Ê\90M\83f\81[\83^\r
+struct CommunicationData{\r
+       // \83f\81[\83^\82Ì\8eí\97Þ\r
+       char m_DataType;\r
+       // \83f\81[\83^\r
+       union{\r
+               struct{\r
+                       char m_Name[MAX_AVATAR_NAME_LENGTH];\r
+               } m_LoginData;\r
+               struct{\r
+                       // \97L\8cø\82©\82Ç\82¤\82©\r
+                       char m_Enable;\r
+                       // \96¼\91O\r
+                       char m_Name[MAX_AVATAR_NAME_LENGTH];\r
+                       // \8dÀ\95W\r
+                       double m_Position[3];\r
+                       // \95û\8cü\r
+                       double m_Direction[3];\r
+                       // \83T\83C\83Y\r
+                       double m_Radias;\r
+               } m_AvatarData;\r
+               struct{\r
+                       char m_CommandType;\r
+               } m_ActionCommand;\r
+               // \89¹\90º\r
+               VoiceData m_Voice;\r
+               // \83f\81[\83^\83T\83C\83Y\92²\90®\r
+               char m_Dummy[MAX_COMMUNICATION_DATA_LENGTH - 1];\r
+       } m_Data;\r
+};\r
+\r
+#endif // INC_DATA\r
index 242f592..5e41e50 100644 (file)
@@ -1,21 +1,21 @@
-// \8b\9e
-
-#ifdef WIN32
-       #pragma warning(disable : 4244)     // MIPS
-       #pragma warning(disable : 4136)     // X86
-       #pragma warning(disable : 4051)     // ALPHA
-
-       //#pragma comment(linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"")
-
-       // \8cÃ\82¢\8aÖ\90\94\82Ì\8cx\8d\90\82ð\92â\8e~
-       #pragma warning(disable: 4996)
-       #pragma warning(disable: 4786)
-#endif // WIN32
-
-
-
-
-#ifndef INC_ENVIRONMENT
-#define INC_ENVIRONMENT
-
-#endif // INC_ENVIRONMENT
+// \8b\9e\r
+\r
+#ifdef WIN32\r
+       #pragma warning(disable : 4244)     // MIPS\r
+       #pragma warning(disable : 4136)     // X86\r
+       #pragma warning(disable : 4051)     // ALPHA\r
+\r
+       //#pragma comment(linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"")\r
+\r
+       // \8cÃ\82¢\8aÖ\90\94\82Ì\8cx\8d\90\82ð\92â\8e~\r
+       #pragma warning(disable: 4996)\r
+       #pragma warning(disable: 4786)\r
+#endif // WIN32\r
+\r
+\r
+\r
+\r
+#ifndef INC_ENVIRONMENT\r
+#define INC_ENVIRONMENT\r
+\r
+#endif // INC_ENVIRONMENT\r
index 571149b..87f0044 100644 (file)
@@ -1,21 +1,21 @@
-\81\9b\83f\83B\83\8c\83N\83g\83\8a\82Ì\8eg\82¢\95û
-\81uOS\81v\81A\81u\83R\83\93\83p\83C\83\89\81v\81A\81u\8b@\94\\81v\82²\82Æ\82É\83f\83B\83\8c\83N\83g\83\8a\82ð\8dì\90¬\82µ\81A\82»\82ê\82¼\82ê\82Ì\96¼\91O\82ð\95t\82¯\82é\81B
-  \97á
-    OS: Linux\81A\83R\83\93\83p\83C\83\89: gcc\81A\8b@\94\: \83N\83\89\83C\83A\83\93\83g\82Ì\8fê\8d\87\81A\81ulinux_gcc_client\81v
-
-
-\97á\8aO
-  \91¼\82Ì\97v\91f\82Å\95K\82¸\8c\88\82Ü\82é\82à\82Ì\82Í\8fÈ\82­
-  \97á
-    Visual C++\82Ì\82æ\82¤\82È\83R\83\93\83p\83C\83\89\82Í\81AOS\82ªWindows\8cÀ\92è\82È\82Ì\82Å\81AOS\96¼\82Í\8fÈ\82­
-      vc2010_client
-
-
-
-
-
-\81\9b\82¨\92m\82ç\82¹\81i\91¼\82Ì\90l\82Ö\82Ì\88ê\8c¾\81j
-OS\82â\83R\83\93\83p\83C\83\89\82É\88Ë\91\82µ\82È\82¢\83\\81[\83X\83R\81[\83h\82ð\88ê\82Â\82É\82Ü\82Æ\82ß\8dÄ\97\98\97p\82µ\82â\82·\82¢\82æ\82¤\82É\82·\82é\81Bcommon\83f\83B\83\8c\83N\83g\83\8a\81B
-
-\81¦\90V\82½\82È\83\8b\81[\83\8b\81A\91¼\82Ì\90l\82Ö\82Ì\82¨\92m\82ç\82¹\82ª\82 \82é\8fê\8d\87\82Í\90\8f\8e\9e\8dX\90V\82µ\82Ä\82­\82¾\82³\82¢\81B
-
+\81\9b\83f\83B\83\8c\83N\83g\83\8a\82Ì\8eg\82¢\95û\r
+\81uOS\81v\81A\81u\83R\83\93\83p\83C\83\89\81v\81A\81u\8b@\94\\81v\82²\82Æ\82É\83f\83B\83\8c\83N\83g\83\8a\82ð\8dì\90¬\82µ\81A\82»\82ê\82¼\82ê\82Ì\96¼\91O\82ð\95t\82¯\82é\81B\r
+  \97á\r
+    OS: Linux\81A\83R\83\93\83p\83C\83\89: gcc\81A\8b@\94\: \83N\83\89\83C\83A\83\93\83g\82Ì\8fê\8d\87\81A\81ulinux_gcc_client\81v\r
+\r
+\r
+\97á\8aO\r
+  \91¼\82Ì\97v\91f\82Å\95K\82¸\8c\88\82Ü\82é\82à\82Ì\82Í\8fÈ\82­\r
+  \97á\r
+    Visual C++\82Ì\82æ\82¤\82È\83R\83\93\83p\83C\83\89\82Í\81AOS\82ªWindows\8cÀ\92è\82È\82Ì\82Å\81AOS\96¼\82Í\8fÈ\82­\r
+      vc2010_client\r
+\r
+\r
+\r
+\r
+\r
+\81\9b\82¨\92m\82ç\82¹\81i\91¼\82Ì\90l\82Ö\82Ì\88ê\8c¾\81j\r
+OS\82â\83R\83\93\83p\83C\83\89\82É\88Ë\91\82µ\82È\82¢\83\\81[\83X\83R\81[\83h\82ð\88ê\82Â\82É\82Ü\82Æ\82ß\8dÄ\97\98\97p\82µ\82â\82·\82¢\82æ\82¤\82É\82·\82é\81Bcommon\83f\83B\83\8c\83N\83g\83\8a\81B\r
+\r
+\81¦\90V\82½\82È\83\8b\81[\83\8b\81A\91¼\82Ì\90l\82Ö\82Ì\82¨\92m\82ç\82¹\82ª\82 \82é\8fê\8d\87\82Í\90\8f\8e\9e\8dX\90V\82µ\82Ä\82­\82¾\82³\82¢\81B\r
+\r
index 2cf9584..070aae2 100644 (file)
@@ -1,20 +1,20 @@
-
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual C++ Express 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vc2010_client", "vc2010_client\vc2010_client.vcxproj", "{B25CF9CE-B08B-4647-A84F-C5B9B13D42AB}"
-EndProject
-Global
-       GlobalSection(SolutionConfigurationPlatforms) = preSolution
-               Debug|Win32 = Debug|Win32
-               Release|Win32 = Release|Win32
-       EndGlobalSection
-       GlobalSection(ProjectConfigurationPlatforms) = postSolution
-               {B25CF9CE-B08B-4647-A84F-C5B9B13D42AB}.Debug|Win32.ActiveCfg = Debug|Win32
-               {B25CF9CE-B08B-4647-A84F-C5B9B13D42AB}.Debug|Win32.Build.0 = Debug|Win32
-               {B25CF9CE-B08B-4647-A84F-C5B9B13D42AB}.Release|Win32.ActiveCfg = Release|Win32
-               {B25CF9CE-B08B-4647-A84F-C5B9B13D42AB}.Release|Win32.Build.0 = Release|Win32
-       EndGlobalSection
-       GlobalSection(SolutionProperties) = preSolution
-               HideSolutionNode = FALSE
-       EndGlobalSection
-EndGlobal
+\r
+Microsoft Visual Studio Solution File, Format Version 11.00\r
+# Visual C++ Express 2010\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vc2010_client", "vc2010_client\vc2010_client.vcxproj", "{B25CF9CE-B08B-4647-A84F-C5B9B13D42AB}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|Win32 = Debug|Win32\r
+               Release|Win32 = Release|Win32\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {B25CF9CE-B08B-4647-A84F-C5B9B13D42AB}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {B25CF9CE-B08B-4647-A84F-C5B9B13D42AB}.Debug|Win32.Build.0 = Debug|Win32\r
+               {B25CF9CE-B08B-4647-A84F-C5B9B13D42AB}.Release|Win32.ActiveCfg = Release|Win32\r
+               {B25CF9CE-B08B-4647-A84F-C5B9B13D42AB}.Release|Win32.Build.0 = Release|Win32\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
index 633fa2b..181eac0 100644 (file)
@@ -1,76 +1,76 @@
-#include "CClient.h"
-
-#include <iostream>
-
-////////////////////////////////////////////////////////////////////////////////
-// constructor
-////////////////////////////////////////////////////////////////////////////////
-CClient::CClient()
-{
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// destructor
-////////////////////////////////////////////////////////////////////////////////
-CClient::~CClient()
-{
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// initialize
-////////////////////////////////////////////////////////////////////////////////
-bool CClient::initialize()
-{
-       m_UI.setModel(&m_Model);
-       m_UI.initialize();
-       m_Model.initialize();
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// mail loop
-////////////////////////////////////////////////////////////////////////////////
-void CClient::mainloop()
-{
-       // \82Æ\82è\82 \82¦\82¸\96³\8cÀ\83\8b\81[\83v\82É\93ü\82é
-
-       m_UI.start();
-
-       while(true){
-               if(m_UI.existEvent()){
-                       ClientInputEvent a_Event = m_UI.getEvent();
-                       if(a_Event == "CONNECT"){
-                               m_Model.addEvent("CONNECT");
-                       }
-                       else if(a_Event == "DISCONNECT"){
-                               m_Model.addEvent("DISCONNECT");
-                       }
-                       else if(a_Event == "LOGIN"){
-                               m_Model.addEvent("LOGIN");
-                       }
-                       else if(a_Event == "LOGOUT"){
-                               m_Model.addEvent("LOGOUT");
-                       }
-                       else if(a_Event == "POSITION"){
-                               m_Model.addEvent("POSITION");
-                       }
-                       else if(a_Event == "FRONT"){
-                               m_Model.addEvent("FRONT");
-                       }
-                       else if(a_Event == "BACK"){
-                               m_Model.addEvent("BACK");
-                       }
-                       else if(a_Event == "TURN_RIGHT"){
-                               m_Model.addEvent("TURN_RIGHT");
-                       }
-                       else if(a_Event == "TURN_LEFT"){
-                               m_Model.addEvent("TURN_LEFT");
-                       }
-                       else if(a_Event == "END"){
-                               break;
-                       }
-               }
-               m_Model.process();
-               Sleep(1);
-       }
-}
+#include "CClient.h"\r
+\r
+#include <iostream>\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// constructor\r
+////////////////////////////////////////////////////////////////////////////////\r
+CClient::CClient()\r
+{\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// destructor\r
+////////////////////////////////////////////////////////////////////////////////\r
+CClient::~CClient()\r
+{\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// initialize\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CClient::initialize()\r
+{\r
+       m_UI.setModel(&m_Model);\r
+       m_UI.initialize();\r
+       m_Model.initialize();\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// mail loop\r
+////////////////////////////////////////////////////////////////////////////////\r
+void CClient::mainloop()\r
+{\r
+       // \82Æ\82è\82 \82¦\82¸\96³\8cÀ\83\8b\81[\83v\82É\93ü\82é\r
+\r
+       m_UI.start();\r
+\r
+       while(true){\r
+               if(m_UI.existEvent()){\r
+                       ClientInputEvent a_Event = m_UI.getEvent();\r
+                       if(a_Event == "CONNECT"){\r
+                               m_Model.addEvent("CONNECT");\r
+                       }\r
+                       else if(a_Event == "DISCONNECT"){\r
+                               m_Model.addEvent("DISCONNECT");\r
+                       }\r
+                       else if(a_Event == "LOGIN"){\r
+                               m_Model.addEvent("LOGIN");\r
+                       }\r
+                       else if(a_Event == "LOGOUT"){\r
+                               m_Model.addEvent("LOGOUT");\r
+                       }\r
+                       else if(a_Event == "POSITION"){\r
+                               m_Model.addEvent("POSITION");\r
+                       }\r
+                       else if(a_Event == "FRONT"){\r
+                               m_Model.addEvent("FRONT");\r
+                       }\r
+                       else if(a_Event == "BACK"){\r
+                               m_Model.addEvent("BACK");\r
+                       }\r
+                       else if(a_Event == "TURN_RIGHT"){\r
+                               m_Model.addEvent("TURN_RIGHT");\r
+                       }\r
+                       else if(a_Event == "TURN_LEFT"){\r
+                               m_Model.addEvent("TURN_LEFT");\r
+                       }\r
+                       else if(a_Event == "END"){\r
+                               break;\r
+                       }\r
+               }\r
+               m_Model.process();\r
+               Sleep(1);\r
+       }\r
+}\r
index fe0dc91..5551e14 100644 (file)
@@ -1,90 +1,90 @@
-#ifndef INC_CClient
-#define INC_CClient
-
-// \83C\83\93\83N\83\8b\81[\83h\82Í\95K\82¸\95K\97v\82È\95¨\82¾\82¯
-// \93à\95\94\82Å\97\98\97p\82·\82é\82¾\82¯\82Ì\95¨\82Í\83\\81[\83X\82É\8bL\8fq
-#include "CClientModel.h"
-#include "CClientUI.h"
-
-// \8aÖ\90\94\96¼\82Í\83\8d\81[\83\8f\83L\83\83\83\81\83\8b\83P\81[\83X\82Æ\82·\82é
-
-////////////////////////////////////////////////////////////////////////////////
-// CClient
-////////////////////////////////////////////////////////////////////////////////
-class CClient
-{
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83\81\83\93\83o\95Ï\90\94
-       ////////////////////////////////////////////////////////////////////////////////
-private:
-       CClientUI m_UI;
-       CClientModel m_Model;
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83R\83\93\83X\83g\83\89\83N\83^
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       CClient();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83f\83X\83g\83\89\83N\83^
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       ~CClient();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \91\80\8dì\83\81\83\\83b\83h
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       // \8f\89\8aú\89»
-       bool initialize();
-       // main loop
-       void mainloop();
-
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \91®\90«\83\81\83\\83b\83h
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       // \8bN\93®\83p\83\89\83\81\81[\83^\82ð\93ü\97Í\82·\82é
-       void setArgement(int* in_pArgc, char** in_ppArgv)
-       {
-               m_UI.setArgement(in_pArgc, in_ppArgv);
-       }
-
-public:
-       // \83\8d\83O\83C\83\93\96¼\82ð\93ü\97Í\82·\82é
-       void setLoginName(std::string in_LoginName)
-       {
-               m_Model.setLoginName(in_LoginName);
-       }
-
-       void setServerAddress(const char* in_pIpAddress, unsigned short in_PortNumber)
-       {
-               m_Model.setServerAddress(in_pIpAddress, in_PortNumber);
-       }
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83C\83e\83\8c\81[\83V\83\87\83\93
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \8fó\91Ô
-       ////////////////////////////////////////////////////////////////////////////////
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \89\89\8eZ\8eq
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \8f\83\90\88\89¼\91z\8aÖ\90\94\81A\92è\8b`\82Ì\82Ý\81i\94ñ\8eÀ\91\95\92ñ\8b\9f\81j
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \93à\95\94\83N\83\89\83X
-       ////////////////////////////////////////////////////////////////////////////////
-
-
-};
-
-#endif //INC_CClient
+#ifndef INC_CClient\r
+#define INC_CClient\r
+\r
+// \83C\83\93\83N\83\8b\81[\83h\82Í\95K\82¸\95K\97v\82È\95¨\82¾\82¯\r
+// \93à\95\94\82Å\97\98\97p\82·\82é\82¾\82¯\82Ì\95¨\82Í\83\\81[\83X\82É\8bL\8fq\r
+#include "CClientModel.h"\r
+#include "CClientUI.h"\r
+\r
+// \8aÖ\90\94\96¼\82Í\83\8d\81[\83\8f\83L\83\83\83\81\83\8b\83P\81[\83X\82Æ\82·\82é\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// CClient\r
+////////////////////////////////////////////////////////////////////////////////\r
+class CClient\r
+{\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83\81\83\93\83o\95Ï\90\94\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+private:\r
+       CClientUI m_UI;\r
+       CClientModel m_Model;\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83R\83\93\83X\83g\83\89\83N\83^\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       CClient();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83f\83X\83g\83\89\83N\83^\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       ~CClient();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \91\80\8dì\83\81\83\\83b\83h\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       // \8f\89\8aú\89»\r
+       bool initialize();\r
+       // main loop\r
+       void mainloop();\r
+\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \91®\90«\83\81\83\\83b\83h\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       // \8bN\93®\83p\83\89\83\81\81[\83^\82ð\93ü\97Í\82·\82é\r
+       void setArgement(int* in_pArgc, char** in_ppArgv)\r
+       {\r
+               m_UI.setArgement(in_pArgc, in_ppArgv);\r
+       }\r
+\r
+public:\r
+       // \83\8d\83O\83C\83\93\96¼\82ð\93ü\97Í\82·\82é\r
+       void setLoginName(std::string in_LoginName)\r
+       {\r
+               m_Model.setLoginName(in_LoginName);\r
+       }\r
+\r
+       void setServerAddress(const char* in_pIpAddress, unsigned short in_PortNumber)\r
+       {\r
+               m_Model.setServerAddress(in_pIpAddress, in_PortNumber);\r
+       }\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83C\83e\83\8c\81[\83V\83\87\83\93\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \8fó\91Ô\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \89\89\8eZ\8eq\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \8f\83\90\88\89¼\91z\8aÖ\90\94\81A\92è\8b`\82Ì\82Ý\81i\94ñ\8eÀ\91\95\92ñ\8b\9f\81j\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \93à\95\94\83N\83\89\83X\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+\r
+\r
+};\r
+\r
+#endif //INC_CClient\r
index 502019d..48fc251 100644 (file)
-// \8b\9e
-#include "../../common/Environment.h"
-
-#include "CClientModel.h"
-
-#include <iostream>
-#include <string>
-
-
-////////////////////////////////////////////////////////////////////////////////
-// constructor
-////////////////////////////////////////////////////////////////////////////////
-CClientModel::CClientModel()
-{
-       m_isLogin = false;
-       initializeSpeex(&m_SpeexData);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// destructor
-////////////////////////////////////////////////////////////////////////////////
-CClientModel::~CClientModel()
-{
-       uninitializeSpeex(&m_SpeexData);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// initialize
-////////////////////////////////////////////////////////////////////////////////
-bool CClientModel::initialize()
-{
-       m_Connection.initialize();
-
-       // \8c»\8fóbuffer_size\82ª160\82Ì\94{\90\94\82Å\82È\82¯\82ê\82Î\81A\88³\8fk\82Ì\8aÖ\8cW\8fã\82»\82Ì\8aÔ\82É\83m\83C\83Y\82ª\93ü\82é
-       // buffer_size = 22050 * bitrate / 8 * channel * time / 1000;
-       // buffer_size \82ª160\82Ì\94{\90\94
-
-       // \88ê\94Ê\93I\82É\82Í\83o\83b\83t\83@\82Í\98A\91±\82µ\82Ä\82¢\82é\82½\82ß\81A\8dD\82«\82È\88Ê\92u\82Å\90Ø\82é\82±\82Æ\82ª\89Â\94\\82¾\82ª\81A\8c»\8fó\82Ì
-       // \8dì\82è\82Å\82Í\83o\83b\83t\83@\82ð\83\8a\83\93\83O\83o\83b\83t\83@\82Æ\82µ\82Ä\95ª\8a\84\82µ\82Ä\82¢\82é\82½\82ß\81A\8dD\82«\82È\88Ê\92u\82Å\90Ø\82é\82±\82Æ\82ª\82Å\82«\82È\82¢\81B
-       // \82æ\82Á\82Ä\81A\8d¡\8cã\82Í\83o\83b\83t\83@\82ð\8dD\82«\82È\8aÔ\8au\82Å\90Ø\82é\82±\82Æ\82ª\89Â\94\\82È\8dì\82è\82É\82·\82é\95K\97v\82ª\82 \82é\81B
-
-       m_InputWave.initialize();
-       //m_InputWave.setDataFullCallBack(&DataFullCallBackFunction);
-       if(!m_InputWave.open()){
-               return 0;
-       }
-
-       m_OutputWave.initialize();
-       if(!m_OutputWave.open()){
-               return 0;
-       }
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// initialize of speex
-////////////////////////////////////////////////////////////////////////////////
-bool CClientModel::initializeSpeex(SpeexData* io_pSpeexData)
-{
-       io_pSpeexData->st = speex_encoder_init(speex_lib_get_mode(SPEEX_MODEID_NB));
-       io_pSpeexData->dec = speex_decoder_init(speex_lib_get_mode(SPEEX_MODEID_NB));
-
-       /* BEGIN: You probably don't need the following in a real application */
-#if 0
-       callback.callback_id = SPEEX_INBAND_CHAR;
-       callback.func = speex_std_char_handler;
-       callback.data = stderr;
-       speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);
-
-       callback.callback_id = SPEEX_INBAND_MODE_REQUEST;
-       callback.func = speex_std_mode_request_handler;
-       callback.data = st;
-       speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);
-#endif
-       /* END of unnecessary stuff */
-
-       spx_int32_t tmp;
-       tmp=1;
-       speex_decoder_ctl(io_pSpeexData->dec, SPEEX_SET_ENH, &tmp);
-       tmp=0;
-       speex_encoder_ctl(io_pSpeexData->st, SPEEX_SET_VBR, &tmp);
-       tmp=8;
-       speex_encoder_ctl(io_pSpeexData->st, SPEEX_SET_QUALITY, &tmp);
-       /*
-       tmp=1;
-       speex_encoder_ctl(st, SPEEX_SET_COMPLEXITY, &tmp);
-       */
-       tmp = 8000;
-       //speex_encoder_ctl(st, SPEEX_SET_SAMPLING_RATE, &tmp);
-       //speex_decoder_ctl(dec, SPEEX_SET_SAMPLING_RATE, &tmp);
-       //tmp = 8000;
-       //speex_encoder_ctl(st, SPEEX_SET_BITRATE, &tmp);
-
-       spx_int32_t frame_size;
-       speex_encoder_ctl(io_pSpeexData->st, SPEEX_GET_FRAME_SIZE, &frame_size);
-
-       /* Turn this off if you want to measure SNR (on by default) */
-       /*
-       tmp=1;
-       speex_encoder_ctl(st, SPEEX_SET_HIGHPASS, &tmp);
-       speex_decoder_ctl(dec, SPEEX_SET_HIGHPASS, &tmp);
-       */
-
-       speex_encoder_ctl(io_pSpeexData->st, SPEEX_GET_LOOKAHEAD, &io_pSpeexData->skip_group_delay);
-       speex_decoder_ctl(io_pSpeexData->dec, SPEEX_GET_LOOKAHEAD, &tmp);
-       io_pSpeexData->skip_group_delay += tmp;
-
-       speex_bits_init(&io_pSpeexData->bits);
-
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// uninitialize of speex
-////////////////////////////////////////////////////////////////////////////////
-bool CClientModel::uninitializeSpeex(SpeexData* io_pSpeexData)
-{
-       speex_encoder_destroy(io_pSpeexData->st);
-       speex_decoder_destroy(io_pSpeexData->dec);
-       speex_bits_destroy(&io_pSpeexData->bits);
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \83C\83x\83\93\83g\92Ç\89Á
-////////////////////////////////////////////////////////////////////////////////
-bool CClientModel::addEvent(std::string in_Event)
-{
-       m_Events.push_back(in_Event);
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \8f\88\97\9d
-////////////////////////////////////////////////////////////////////////////////
-bool CClientModel::process()
-{
-       // \92Ê\90M\83N\83\89\83X\82©\82ç\83f\81[\83^\8eæ\93¾
-       CommunicationData* a_pData;
-       if(m_Connection.receive(&a_pData)){
-               // \8dÀ\95W\83f\81[\83^\82Ì\8fê\8d\87
-               if(a_pData->m_DataType == 'p'){
-                       // \93¯\82\96¼\91O\82Ì\83A\83o\83^\81[\82ª\91\8dÝ\82·\82é\82©\83`\83F\83b\83N\82·\82é
-                       bool check = false;
-                       AvatarInformationList::iterator p = m_AvatarInformations.begin();
-                       while(true){
-                               // \93¯\82\96¼\91O\82Ì\83A\83o\83^\81[\82ª\91\8dÝ\82µ\82È\82¢\8fê\8d\87\81A\90V\82½\82É\8dì\90¬\82·\82é
-                               if(p == m_AvatarInformations.end()){
-                                       AvatarInformation temp;
-                                       strcpy(temp.m_Name, a_pData->m_Data.m_AvatarData.m_Name);
-                                       m_AvatarInformations.push_front(temp);
-                                       p = m_AvatarInformations.begin();
-                                       break;
-                               }
-                               if(strcmp(p->m_Name, a_pData->m_Data.m_AvatarData.m_Name) == 0){
-                                       break;
-                               }
-                               p++;
-                       }
-                       p->m_Position[0] = a_pData->m_Data.m_AvatarData.m_Position[0];
-                       p->m_Position[1] = a_pData->m_Data.m_AvatarData.m_Position[1];
-                       p->m_Position[2] = a_pData->m_Data.m_AvatarData.m_Position[2];
-                       p->m_Direction[0] = a_pData->m_Data.m_AvatarData.m_Direction[0];
-                       p->m_Direction[1] = a_pData->m_Data.m_AvatarData.m_Direction[1];
-                       p->m_Direction[2] = a_pData->m_Data.m_AvatarData.m_Direction[2];
-                       p->m_Radias = a_pData->m_Data.m_AvatarData.m_Radias;
-               }
-               // \89¹\90º\83f\81[\83^\82Ì\8fê\8d\87
-               if(a_pData->m_DataType == 'v'){
-                       static char buffer[3000];
-                       static int length = 0;
-                       short out_short[FRAME_SIZE];
-
-                       // \83\8a\83Z\83b\83g
-                       //speex_bits_reset(&m_SpeexData.bits);
-
-                       // \88³\8fk\83r\83b\83g\83X\83g\83\8a\81[\83\80\82ð\83Z\83b\83g\81i\93¯\8e\9e\82É\83\8a\83Z\83b\83g\82³\82ê\82é\81j
-                       speex_bits_read_from(&m_SpeexData.bits, a_pData->m_Data.m_Voice.m_Stream, a_pData->m_Data.m_Voice.m_Length);
-
-                       // \89ð\93\80
-                       speex_decode_int(m_SpeexData.dec, &m_SpeexData.bits, out_short);
-
-                       // Convert 16 -> 8 bits
-                       for(int i = 0; i < FRAME_SIZE; i++){
-                               buffer[length] = (out_short[i] ^ 0x8000) >> 8;
-                               length++;
-                       }
-
-                       if(a_pData->m_Data.m_Voice.m_isEnd){
-                               StructWaveBuffer a_OutputWaveData;
-                               a_OutputWaveData.m_pWaveBuffer = buffer;
-                               a_OutputWaveData.m_BufferSize = length;
-                               a_OutputWaveData.m_RecorMilliSecond = 100;
-                               m_OutputWave.setWaveDataPointer(&a_OutputWaveData);
-                               length = 0;
-                               //std::cout << "reset" << std::endl;
-                       }
-               }
-       }
-
-       // \83C\83x\83\93\83g\8f\88\97\9d
-       if(!m_Events.empty()){
-               std::string& a_rEvent = m_Events.front();
-               // connect
-               if(a_rEvent == "CONNECT"){
-                       //m_Connection.connection();
-                       if(m_Connection.connection(m_IpAddress, m_PortNumber)){
-                               std::cout << "seccess connection" << std::endl;
-                       }
-                       else{
-                               std::cout << "failure connection" << std::endl;
-                       }
-               }
-               // disconnect
-               else if(a_rEvent == "DISCONNECT"){
-                       if(m_Connection.disconnection()){
-                               std::cout << "sccess disconnection" << std::endl;
-                       }
-                       else{
-                               std::cout << "failure disconnection" << std::endl;
-                       }
-               }
-               // \83\8d\83O\83C\83\93\8f\88\97\9d
-               else if(a_rEvent == "LOGIN"){
-                       m_Connection.login(m_LoginName.c_str());
-                       m_isLogin = true;
-               }
-               // \83\8d\83O\83A\83E\83g
-               else if(a_rEvent == "LOGOUT"){
-                       m_isLogin = false;
-                       m_Connection.logout();
-               }
-               // \8dÀ\95W\8eæ\93¾
-               else if(a_rEvent == "POSITION"){
-                       m_Connection.requestPosition();
-               }
-               // \83A\83N\83V\83\87\83\93\83R\83}\83\93\83h
-               // \91O\95û\82Ö\88Ú\93®
-               else if(a_rEvent == "FRONT"){
-                       m_Connection.requestMove('f');
-               }
-               // \8cã\95û\82Ö\88Ú\93®
-               else if(a_rEvent == "BACK"){
-                       m_Connection.requestMove('b');
-               }
-               // \89E\90ù\89ñ
-               else if(a_rEvent == "TURN_RIGHT"){
-                       m_Connection.requestMove('r');
-               }
-               // \8d\90ù\89ñ
-               else if(a_rEvent == "TURN_LEFT"){
-                       m_Connection.requestMove('l');
-                       m_InputWave.getWaveDataPointer();
-               }
-
-               m_Events.pop_front();
-       }
-
-       try{
-               if(m_isLogin){
-                       m_InputWave.start();
-                       m_OutputWave.start();
-               }
-               else{
-                       m_InputWave.stop();
-                       m_OutputWave.stop();
-               }
-       }
-       catch(char* str){
-               std::cout << str << std::endl;
-       }
-
-       // \89¹\90º\93ü\97Í
-#if 0
-       m_OutputWave.setWaveDataPointer(m_InputWave.getWaveDataPointer());
-#else
-       StructWaveBuffer* a_pInputWaveData = m_InputWave.getWaveDataPointer();
-       if(a_pInputWaveData != NULL){
-               char* p1 = a_pInputWaveData->m_pWaveBuffer;
-
-               short in_short[FRAME_SIZE];
-
-               int bitCount = 0;
-               while(true){
-                       // \88³\8fk
-                       // Convert 8 -> 16 bits
-                       for(int i = 0; i < FRAME_SIZE; i++){
-                               // \97Ê\8eq\89»\83r\83b\83g\90\94\82ª8\83r\83b\83g\82Ì\8fê\8d\87\82Í\81A0\81`255 \82Ì\94Í\88Í\82Å\90U\95\9d\92l\82ð\95\\8c»\82µ\82Ü\82·\81B128 \82ª\92\86\90S(\90U\95\9d\82È\82µ)\82Å\82·\81B
-                               // 16\83r\83b\83g\82Ì\8fê\8d\87\82Í\81A-32768\81`32767 \82Ì\94Í\88Í\82Å\90U\95\9d\92l\82ð\95\\8c»\82µ\82Ü\82·\81B0 \82ª\92\86\90S(\90U\95\9d\82È\82µ)\82Å\82·\81B
-                               if(p1 < a_pInputWaveData->m_pWaveBuffer + a_pInputWaveData->m_BufferSize){
-                                       in_short[i] = (*(p1 + i) << 8) ^ 0x8000;
-                               }
-                               else{
-                                       in_short[i] = (128 << 8) ^ 0x8000;
-                               }
-                       }
-                       p1 += FRAME_SIZE;
-
-                       // \83\8a\83Z\83b\83g
-                       speex_bits_reset(&m_SpeexData.bits);
-
-                       // \88³\8fk
-                       speex_encode_int(m_SpeexData.st, in_short, &m_SpeexData.bits);
-
-                       // \88³\8fk\83r\83b\83g\83X\83g\83\8a\81[\83\80\8eæ\93¾
-                       char cbits[200];
-                       int nbBytes = speex_bits_write(&m_SpeexData.bits, cbits, 200);
-                       bitCount += m_SpeexData.bits.nbBits;
-
-                       // \91\97\90M
-                       if(p1 >= a_pInputWaveData->m_pWaveBuffer + a_pInputWaveData->m_BufferSize){
-                               m_Connection.sendVoice(cbits, nbBytes, 1);
-                               break;
-                       }
-                       else{
-                               m_Connection.sendVoice(cbits, nbBytes, 0);
-                       }
-               }
-       }
-#endif
-
-       return true;
-}
-
+// \8b\9e\r
+#include "../../common/Environment.h"\r
+\r
+#include "CClientModel.h"\r
+\r
+#include <iostream>\r
+#include <string>\r
+\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// constructor\r
+////////////////////////////////////////////////////////////////////////////////\r
+CClientModel::CClientModel()\r
+{\r
+       m_isLogin = false;\r
+       initializeSpeex(&m_SpeexData);\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// destructor\r
+////////////////////////////////////////////////////////////////////////////////\r
+CClientModel::~CClientModel()\r
+{\r
+       uninitializeSpeex(&m_SpeexData);\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// initialize\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CClientModel::initialize()\r
+{\r
+       m_Connection.initialize();\r
+\r
+       // \8c»\8fóbuffer_size\82ª160\82Ì\94{\90\94\82Å\82È\82¯\82ê\82Î\81A\88³\8fk\82Ì\8aÖ\8cW\8fã\82»\82Ì\8aÔ\82É\83m\83C\83Y\82ª\93ü\82é\r
+       // buffer_size = 22050 * bitrate / 8 * channel * time / 1000;\r
+       // buffer_size \82ª160\82Ì\94{\90\94\r
+\r
+       // \88ê\94Ê\93I\82É\82Í\83o\83b\83t\83@\82Í\98A\91±\82µ\82Ä\82¢\82é\82½\82ß\81A\8dD\82«\82È\88Ê\92u\82Å\90Ø\82é\82±\82Æ\82ª\89Â\94\\82¾\82ª\81A\8c»\8fó\82Ì\r
+       // \8dì\82è\82Å\82Í\83o\83b\83t\83@\82ð\83\8a\83\93\83O\83o\83b\83t\83@\82Æ\82µ\82Ä\95ª\8a\84\82µ\82Ä\82¢\82é\82½\82ß\81A\8dD\82«\82È\88Ê\92u\82Å\90Ø\82é\82±\82Æ\82ª\82Å\82«\82È\82¢\81B\r
+       // \82æ\82Á\82Ä\81A\8d¡\8cã\82Í\83o\83b\83t\83@\82ð\8dD\82«\82È\8aÔ\8au\82Å\90Ø\82é\82±\82Æ\82ª\89Â\94\\82È\8dì\82è\82É\82·\82é\95K\97v\82ª\82 \82é\81B\r
+\r
+       m_InputWave.initialize();\r
+       //m_InputWave.setDataFullCallBack(&DataFullCallBackFunction);\r
+       if(!m_InputWave.open()){\r
+               return 0;\r
+       }\r
+\r
+       m_OutputWave.initialize();\r
+       if(!m_OutputWave.open()){\r
+               return 0;\r
+       }\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// initialize of speex\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CClientModel::initializeSpeex(SpeexData* io_pSpeexData)\r
+{\r
+       io_pSpeexData->st = speex_encoder_init(speex_lib_get_mode(SPEEX_MODEID_NB));\r
+       io_pSpeexData->dec = speex_decoder_init(speex_lib_get_mode(SPEEX_MODEID_NB));\r
+\r
+       /* BEGIN: You probably don't need the following in a real application */\r
+#if 0\r
+       callback.callback_id = SPEEX_INBAND_CHAR;\r
+       callback.func = speex_std_char_handler;\r
+       callback.data = stderr;\r
+       speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);\r
+\r
+       callback.callback_id = SPEEX_INBAND_MODE_REQUEST;\r
+       callback.func = speex_std_mode_request_handler;\r
+       callback.data = st;\r
+       speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);\r
+#endif\r
+       /* END of unnecessary stuff */\r
+\r
+       spx_int32_t tmp;\r
+       tmp=1;\r
+       speex_decoder_ctl(io_pSpeexData->dec, SPEEX_SET_ENH, &tmp);\r
+       tmp=0;\r
+       speex_encoder_ctl(io_pSpeexData->st, SPEEX_SET_VBR, &tmp);\r
+       tmp=8;\r
+       speex_encoder_ctl(io_pSpeexData->st, SPEEX_SET_QUALITY, &tmp);\r
+       /*\r
+       tmp=1;\r
+       speex_encoder_ctl(st, SPEEX_SET_COMPLEXITY, &tmp);\r
+       */\r
+       tmp = 8000;\r
+       //speex_encoder_ctl(st, SPEEX_SET_SAMPLING_RATE, &tmp);\r
+       //speex_decoder_ctl(dec, SPEEX_SET_SAMPLING_RATE, &tmp);\r
+       //tmp = 8000;\r
+       //speex_encoder_ctl(st, SPEEX_SET_BITRATE, &tmp);\r
+\r
+       spx_int32_t frame_size;\r
+       speex_encoder_ctl(io_pSpeexData->st, SPEEX_GET_FRAME_SIZE, &frame_size);\r
+\r
+       /* Turn this off if you want to measure SNR (on by default) */\r
+       /*\r
+       tmp=1;\r
+       speex_encoder_ctl(st, SPEEX_SET_HIGHPASS, &tmp);\r
+       speex_decoder_ctl(dec, SPEEX_SET_HIGHPASS, &tmp);\r
+       */\r
+\r
+       speex_encoder_ctl(io_pSpeexData->st, SPEEX_GET_LOOKAHEAD, &io_pSpeexData->skip_group_delay);\r
+       speex_decoder_ctl(io_pSpeexData->dec, SPEEX_GET_LOOKAHEAD, &tmp);\r
+       io_pSpeexData->skip_group_delay += tmp;\r
+\r
+       speex_bits_init(&io_pSpeexData->bits);\r
+\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// uninitialize of speex\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CClientModel::uninitializeSpeex(SpeexData* io_pSpeexData)\r
+{\r
+       speex_encoder_destroy(io_pSpeexData->st);\r
+       speex_decoder_destroy(io_pSpeexData->dec);\r
+       speex_bits_destroy(&io_pSpeexData->bits);\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83C\83x\83\93\83g\92Ç\89Á\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CClientModel::addEvent(std::string in_Event)\r
+{\r
+       m_Events.push_back(in_Event);\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \8f\88\97\9d\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CClientModel::process()\r
+{\r
+       // \92Ê\90M\83N\83\89\83X\82©\82ç\83f\81[\83^\8eæ\93¾\r
+       CommunicationData* a_pData;\r
+       if(m_Connection.receive(&a_pData)){\r
+               // \8dÀ\95W\83f\81[\83^\82Ì\8fê\8d\87\r
+               if(a_pData->m_DataType == 'p'){\r
+                       // \93¯\82\96¼\91O\82Ì\83A\83o\83^\81[\82ª\91\8dÝ\82·\82é\82©\83`\83F\83b\83N\82·\82é\r
+                       bool check = false;\r
+                       AvatarInformationList::iterator p = m_AvatarInformations.begin();\r
+                       while(true){\r
+                               // \93¯\82\96¼\91O\82Ì\83A\83o\83^\81[\82ª\91\8dÝ\82µ\82È\82¢\8fê\8d\87\81A\90V\82½\82É\8dì\90¬\82·\82é\r
+                               if(p == m_AvatarInformations.end()){\r
+                                       AvatarInformation temp;\r
+                                       strcpy(temp.m_Name, a_pData->m_Data.m_AvatarData.m_Name);\r
+                                       m_AvatarInformations.push_front(temp);\r
+                                       p = m_AvatarInformations.begin();\r
+                                       break;\r
+                               }\r
+                               if(strcmp(p->m_Name, a_pData->m_Data.m_AvatarData.m_Name) == 0){\r
+                                       break;\r
+                               }\r
+                               p++;\r
+                       }\r
+                       p->m_Position[0] = a_pData->m_Data.m_AvatarData.m_Position[0];\r
+                       p->m_Position[1] = a_pData->m_Data.m_AvatarData.m_Position[1];\r
+                       p->m_Position[2] = a_pData->m_Data.m_AvatarData.m_Position[2];\r
+                       p->m_Direction[0] = a_pData->m_Data.m_AvatarData.m_Direction[0];\r
+                       p->m_Direction[1] = a_pData->m_Data.m_AvatarData.m_Direction[1];\r
+                       p->m_Direction[2] = a_pData->m_Data.m_AvatarData.m_Direction[2];\r
+                       p->m_Radias = a_pData->m_Data.m_AvatarData.m_Radias;\r
+               }\r
+               // \89¹\90º\83f\81[\83^\82Ì\8fê\8d\87\r
+               if(a_pData->m_DataType == 'v'){\r
+                       static char buffer[3000];\r
+                       static int length = 0;\r
+                       short out_short[FRAME_SIZE];\r
+\r
+                       // \83\8a\83Z\83b\83g\r
+                       //speex_bits_reset(&m_SpeexData.bits);\r
+\r
+                       // \88³\8fk\83r\83b\83g\83X\83g\83\8a\81[\83\80\82ð\83Z\83b\83g\81i\93¯\8e\9e\82É\83\8a\83Z\83b\83g\82³\82ê\82é\81j\r
+                       speex_bits_read_from(&m_SpeexData.bits, a_pData->m_Data.m_Voice.m_Stream, a_pData->m_Data.m_Voice.m_Length);\r
+\r
+                       // \89ð\93\80\r
+                       speex_decode_int(m_SpeexData.dec, &m_SpeexData.bits, out_short);\r
+\r
+                       // Convert 16 -> 8 bits\r
+                       for(int i = 0; i < FRAME_SIZE; i++){\r
+                               buffer[length] = (out_short[i] ^ 0x8000) >> 8;\r
+                               length++;\r
+                       }\r
+\r
+                       if(a_pData->m_Data.m_Voice.m_isEnd){\r
+                               StructWaveBuffer a_OutputWaveData;\r
+                               a_OutputWaveData.m_pWaveBuffer = buffer;\r
+                               a_OutputWaveData.m_BufferSize = length;\r
+                               a_OutputWaveData.m_RecorMilliSecond = 100;\r
+                               m_OutputWave.setWaveDataPointer(&a_OutputWaveData);\r
+                               length = 0;\r
+                               //std::cout << "reset" << std::endl;\r
+                       }\r
+               }\r
+       }\r
+\r
+       // \83C\83x\83\93\83g\8f\88\97\9d\r
+       if(!m_Events.empty()){\r
+               std::string& a_rEvent = m_Events.front();\r
+               // connect\r
+               if(a_rEvent == "CONNECT"){\r
+                       //m_Connection.connection();\r
+                       if(m_Connection.connection(m_IpAddress, m_PortNumber)){\r
+                               std::cout << "seccess connection" << std::endl;\r
+                       }\r
+                       else{\r
+                               std::cout << "failure connection" << std::endl;\r
+                       }\r
+               }\r
+               // disconnect\r
+               else if(a_rEvent == "DISCONNECT"){\r
+                       if(m_Connection.disconnection()){\r
+                               std::cout << "sccess disconnection" << std::endl;\r
+                       }\r
+                       else{\r
+                               std::cout << "failure disconnection" << std::endl;\r
+                       }\r
+               }\r
+               // \83\8d\83O\83C\83\93\8f\88\97\9d\r
+               else if(a_rEvent == "LOGIN"){\r
+                       m_Connection.login(m_LoginName.c_str());\r
+                       m_isLogin = true;\r
+               }\r
+               // \83\8d\83O\83A\83E\83g\r
+               else if(a_rEvent == "LOGOUT"){\r
+                       m_isLogin = false;\r
+                       m_Connection.logout();\r
+               }\r
+               // \8dÀ\95W\8eæ\93¾\r
+               else if(a_rEvent == "POSITION"){\r
+                       m_Connection.requestPosition();\r
+               }\r
+               // \83A\83N\83V\83\87\83\93\83R\83}\83\93\83h\r
+               // \91O\95û\82Ö\88Ú\93®\r
+               else if(a_rEvent == "FRONT"){\r
+                       m_Connection.requestMove('f');\r
+               }\r
+               // \8cã\95û\82Ö\88Ú\93®\r
+               else if(a_rEvent == "BACK"){\r
+                       m_Connection.requestMove('b');\r
+               }\r
+               // \89E\90ù\89ñ\r
+               else if(a_rEvent == "TURN_RIGHT"){\r
+                       m_Connection.requestMove('r');\r
+               }\r
+               // \8d\90ù\89ñ\r
+               else if(a_rEvent == "TURN_LEFT"){\r
+                       m_Connection.requestMove('l');\r
+                       m_InputWave.getWaveDataPointer();\r
+               }\r
+\r
+               m_Events.pop_front();\r
+       }\r
+\r
+       try{\r
+               if(m_isLogin){\r
+                       m_InputWave.start();\r
+                       m_OutputWave.start();\r
+               }\r
+               else{\r
+                       m_InputWave.stop();\r
+                       m_OutputWave.stop();\r
+               }\r
+       }\r
+       catch(char* str){\r
+               std::cout << str << std::endl;\r
+       }\r
+\r
+       // \89¹\90º\93ü\97Í\r
+#if 0\r
+       m_OutputWave.setWaveDataPointer(m_InputWave.getWaveDataPointer());\r
+#else\r
+       StructWaveBuffer* a_pInputWaveData = m_InputWave.getWaveDataPointer();\r
+       if(a_pInputWaveData != NULL){\r
+               char* p1 = a_pInputWaveData->m_pWaveBuffer;\r
+\r
+               short in_short[FRAME_SIZE];\r
+\r
+               int bitCount = 0;\r
+               while(true){\r
+                       // \88³\8fk\r
+                       // Convert 8 -> 16 bits\r
+                       for(int i = 0; i < FRAME_SIZE; i++){\r
+                               // \97Ê\8eq\89»\83r\83b\83g\90\94\82ª8\83r\83b\83g\82Ì\8fê\8d\87\82Í\81A0\81`255 \82Ì\94Í\88Í\82Å\90U\95\9d\92l\82ð\95\\8c»\82µ\82Ü\82·\81B128 \82ª\92\86\90S(\90U\95\9d\82È\82µ)\82Å\82·\81B\r
+                               // 16\83r\83b\83g\82Ì\8fê\8d\87\82Í\81A-32768\81`32767 \82Ì\94Í\88Í\82Å\90U\95\9d\92l\82ð\95\\8c»\82µ\82Ü\82·\81B0 \82ª\92\86\90S(\90U\95\9d\82È\82µ)\82Å\82·\81B\r
+                               if(p1 < a_pInputWaveData->m_pWaveBuffer + a_pInputWaveData->m_BufferSize){\r
+                                       in_short[i] = (*(p1 + i) << 8) ^ 0x8000;\r
+                               }\r
+                               else{\r
+                                       in_short[i] = (128 << 8) ^ 0x8000;\r
+                               }\r
+                       }\r
+                       p1 += FRAME_SIZE;\r
+\r
+                       // \83\8a\83Z\83b\83g\r
+                       speex_bits_reset(&m_SpeexData.bits);\r
+\r
+                       // \88³\8fk\r
+                       speex_encode_int(m_SpeexData.st, in_short, &m_SpeexData.bits);\r
+\r
+                       // \88³\8fk\83r\83b\83g\83X\83g\83\8a\81[\83\80\8eæ\93¾\r
+                       char cbits[200];\r
+                       int nbBytes = speex_bits_write(&m_SpeexData.bits, cbits, 200);\r
+                       bitCount += m_SpeexData.bits.nbBits;\r
+\r
+                       // \91\97\90M\r
+                       if(p1 >= a_pInputWaveData->m_pWaveBuffer + a_pInputWaveData->m_BufferSize){\r
+                               m_Connection.sendVoice(cbits, nbBytes, 1);\r
+                               break;\r
+                       }\r
+                       else{\r
+                               m_Connection.sendVoice(cbits, nbBytes, 0);\r
+                       }\r
+               }\r
+       }\r
+#endif\r
+\r
+       return true;\r
+}\r
+\r
index 8bee1e2..e194325 100644 (file)
-#ifndef INC_CClientModel
-#define INC_CClientModel
-
-// \83C\83\93\83N\83\8b\81[\83h\82Í\95K\82¸\95K\97v\82È\95¨\82¾\82¯
-// \93à\95\94\82Å\97\98\97p\82·\82é\82¾\82¯\82Ì\95¨\82Í\83\\81[\83X\82É\8bL\8fq
-#include "../../common/Data.h"
-//#include "../../common/CConnection.h"
-#include "../../common/CClientConnection.h"
-#include "../../common/CInputWave.h"
-#include "../../common/COutputWave.h"
-#include "../../common/CWaveData.h"
-
-#include <list>
-
-// \83A\83o\83^\81[\8aÇ\97\9d\83\8a\83X\83g
-typedef std::list<AvatarInformation> AvatarInformationList;
-
-#include <speex/speex.h>
-#pragma comment(lib, "libspeex.lib")
-#pragma comment(lib, "libspeexdsp.lib")
-/* BEGIN: You probably don't need the following in a real application */
-#include <speex/speex_callbacks.h>
-/* END of unnecessary stuff */
-
-struct SpeexData{
-       // \83G\83\93\83R\81[\83_\83n\83\93\83h\83\8b
-       void *st;
-       // \83f\83R\81[\83_\83n\83\93\83h\83\8b
-       void *dec;
-       // \95s\96¾
-       spx_int32_t skip_group_delay;
-       // \95s\96¾
-       SpeexBits bits;
-       /* BEGIN: You probably don't need the following in a real application */
-       SpeexCallback callback;
-       /* END of unnecessary stuff */
-};
-
-static const unsigned int FRAME_SIZE = 160;
-
-
-// \8aÖ\90\94\96¼\82Í\83\8d\81[\83\8f\83L\83\83\83\81\83\8b\83P\81[\83X\82Æ\82·\82é
-
-////////////////////////////////////////////////////////////////////////////////
-// CClientModel
-////////////////////////////////////////////////////////////////////////////////
-class CClientModel
-{
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83\81\83\93\83o\95Ï\90\94
-       ////////////////////////////////////////////////////////////////////////////////
-private:
-       char m_IpAddress[20];
-       unsigned short m_PortNumber;
-
-       // \83A\83o\83^\81[\8dÅ\91å\83\8d\81[\83h\90\94
-       static const int MAX_AVATAR_NUMBER = 10;
-       // \83A\83o\83^\81[
-       AvatarInformationList m_AvatarInformations;
-       // \92Ê\90M\83N\83\89\83X
-       CClientConnection m_Connection;
-
-       // \83\8d\83O\83C\83\93\8fî\95ñ\81i\90³\8am\82È\83\8d\83O\83C\83\93\8fî\95ñ\82Í\92è\8aú\93I\82É\83T\81[\83o\82É\96â\82¢\8d\87\82í\82¹\82é\95K\97v\82 \82è\81j
-       bool m_isLogin;
-
-       // \89¹\90º\83N\83\89\83X
-       CInputWave m_InputWave;
-       COutputWave m_OutputWave;
-
-       // speex\8aÖ\98A
-       SpeexData m_SpeexData;
-
-       std::list<std::string> m_Events;
-
-       // \83\8d\83O\83C\83\93\96¼
-       std::string m_LoginName;
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83R\83\93\83X\83g\83\89\83N\83^
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       CClientModel();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83f\83X\83g\83\89\83N\83^
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       ~CClientModel();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94
-       ////////////////////////////////////////////////////////////////////////////////
-
-               ////////////////////////////////////////////////////////////////////////////////
-       // \91\80\8dì\83\81\83\\83b\83h
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       // \8f\89\8aú\89»
-       bool initialize();
-       // initialize of speex
-       bool initializeSpeex(SpeexData* io_pSpeexData);
-       // uninitialize of speex
-       bool uninitializeSpeex(SpeexData* io_pSpeexData);
-       // \83C\83x\83\93\83g\92Ç\89Á
-       bool addEvent(std::string);
-       // \8f\88\97\9d
-       bool process();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \91®\90«\83\81\83\\83b\83h
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       void setLoginName(std::string in_LoginName)
-       {
-               m_LoginName = in_LoginName;
-       }
-
-       void setServerAddress(const char* in_pIpAddress, unsigned short in_PortNumber)
-       {
-               strcpy(m_IpAddress, in_pIpAddress);
-               m_PortNumber = in_PortNumber;
-       }
-
-       const AvatarInformationList* getAvatarInformationList()
-       {
-               // \95Ê\83X\83\8c\83b\83h\82É\82æ\82è\8f\91\82«\8d\9e\82Ý\82Æ\93¯\8e\9e\82É\93Ç\82Ý\8d\9e\82Þ\89Â\94\\90«\82 \82è\81i\8c»\8dÝ\96¢\91Î\89\9e\81j
-               return &m_AvatarInformations;
-       }
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83C\83e\83\8c\81[\83V\83\87\83\93
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \8fó\91Ô
-       ////////////////////////////////////////////////////////////////////////////////
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \89\89\8eZ\8eq
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \8f\83\90\88\89¼\91z\8aÖ\90\94\81A\92è\8b`\82Ì\82Ý\81i\94ñ\8eÀ\91\95\92ñ\8b\9f\81j
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \93à\95\94\83N\83\89\83X
-       ////////////////////////////////////////////////////////////////////////////////
-
-
-};
-
-#endif //INC_CClientModel
+#ifndef INC_CClientModel\r
+#define INC_CClientModel\r
+\r
+// \83C\83\93\83N\83\8b\81[\83h\82Í\95K\82¸\95K\97v\82È\95¨\82¾\82¯\r
+// \93à\95\94\82Å\97\98\97p\82·\82é\82¾\82¯\82Ì\95¨\82Í\83\\81[\83X\82É\8bL\8fq\r
+#include "../../common/Data.h"\r
+//#include "../../common/CConnection.h"\r
+#include "../../common/CClientConnection.h"\r
+#include "../../common/CInputWave.h"\r
+#include "../../common/COutputWave.h"\r
+#include "../../common/CWaveData.h"\r
+\r
+#include <list>\r
+\r
+// \83A\83o\83^\81[\8aÇ\97\9d\83\8a\83X\83g\r
+typedef std::list<AvatarInformation> AvatarInformationList;\r
+\r
+#include <speex/speex.h>\r
+#pragma comment(lib, "libspeex.lib")\r
+#pragma comment(lib, "libspeexdsp.lib")\r
+/* BEGIN: You probably don't need the following in a real application */\r
+#include <speex/speex_callbacks.h>\r
+/* END of unnecessary stuff */\r
+\r
+struct SpeexData{\r
+       // \83G\83\93\83R\81[\83_\83n\83\93\83h\83\8b\r
+       void *st;\r
+       // \83f\83R\81[\83_\83n\83\93\83h\83\8b\r
+       void *dec;\r
+       // \95s\96¾\r
+       spx_int32_t skip_group_delay;\r
+       // \95s\96¾\r
+       SpeexBits bits;\r
+       /* BEGIN: You probably don't need the following in a real application */\r
+       SpeexCallback callback;\r
+       /* END of unnecessary stuff */\r
+};\r
+\r
+static const unsigned int FRAME_SIZE = 160;\r
+\r
+\r
+// \8aÖ\90\94\96¼\82Í\83\8d\81[\83\8f\83L\83\83\83\81\83\8b\83P\81[\83X\82Æ\82·\82é\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// CClientModel\r
+////////////////////////////////////////////////////////////////////////////////\r
+class CClientModel\r
+{\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83\81\83\93\83o\95Ï\90\94\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+private:\r
+       char m_IpAddress[20];\r
+       unsigned short m_PortNumber;\r
+\r
+       // \83A\83o\83^\81[\8dÅ\91å\83\8d\81[\83h\90\94\r
+       static const int MAX_AVATAR_NUMBER = 10;\r
+       // \83A\83o\83^\81[\r
+       AvatarInformationList m_AvatarInformations;\r
+       // \92Ê\90M\83N\83\89\83X\r
+       CClientConnection m_Connection;\r
+\r
+       // \83\8d\83O\83C\83\93\8fî\95ñ\81i\90³\8am\82È\83\8d\83O\83C\83\93\8fî\95ñ\82Í\92è\8aú\93I\82É\83T\81[\83o\82É\96â\82¢\8d\87\82í\82¹\82é\95K\97v\82 \82è\81j\r
+       bool m_isLogin;\r
+\r
+       // \89¹\90º\83N\83\89\83X\r
+       CInputWave m_InputWave;\r
+       COutputWave m_OutputWave;\r
+\r
+       // speex\8aÖ\98A\r
+       SpeexData m_SpeexData;\r
+\r
+       std::list<std::string> m_Events;\r
+\r
+       // \83\8d\83O\83C\83\93\96¼\r
+       std::string m_LoginName;\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83R\83\93\83X\83g\83\89\83N\83^\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       CClientModel();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83f\83X\83g\83\89\83N\83^\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       ~CClientModel();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+\r
+               ////////////////////////////////////////////////////////////////////////////////\r
+       // \91\80\8dì\83\81\83\\83b\83h\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       // \8f\89\8aú\89»\r
+       bool initialize();\r
+       // initialize of speex\r
+       bool initializeSpeex(SpeexData* io_pSpeexData);\r
+       // uninitialize of speex\r
+       bool uninitializeSpeex(SpeexData* io_pSpeexData);\r
+       // \83C\83x\83\93\83g\92Ç\89Á\r
+       bool addEvent(std::string);\r
+       // \8f\88\97\9d\r
+       bool process();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \91®\90«\83\81\83\\83b\83h\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       void setLoginName(std::string in_LoginName)\r
+       {\r
+               m_LoginName = in_LoginName;\r
+       }\r
+\r
+       void setServerAddress(const char* in_pIpAddress, unsigned short in_PortNumber)\r
+       {\r
+               strcpy(m_IpAddress, in_pIpAddress);\r
+               m_PortNumber = in_PortNumber;\r
+       }\r
+\r
+       const AvatarInformationList* getAvatarInformationList()\r
+       {\r
+               // \95Ê\83X\83\8c\83b\83h\82É\82æ\82è\8f\91\82«\8d\9e\82Ý\82Æ\93¯\8e\9e\82É\93Ç\82Ý\8d\9e\82Þ\89Â\94\\90«\82 \82è\81i\8c»\8dÝ\96¢\91Î\89\9e\81j\r
+               return &m_AvatarInformations;\r
+       }\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83C\83e\83\8c\81[\83V\83\87\83\93\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \8fó\91Ô\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \89\89\8eZ\8eq\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \8f\83\90\88\89¼\91z\8aÖ\90\94\81A\92è\8b`\82Ì\82Ý\81i\94ñ\8eÀ\91\95\92ñ\8b\9f\81j\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \93à\95\94\83N\83\89\83X\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+\r
+\r
+};\r
+\r
+#endif //INC_CClientModel\r
index c91900c..119e250 100644 (file)
-#include "CClientUI.h"
-
-#include <iostream>
-
-#include <Windows.h>
-#include <cstdlib>
-#include <iostream>
-#include <cmath>
-#include <time.h>
-//#include <GL/glut.h>
-#include "glut.h"
-
-#pragma comment(lib, "ws2_32.lib")
-
-#ifndef M_PI
-#define M_PI 3.14159265357989
-#endif // M_PI
-
-
-// key status
-long g_KeyStatus = 0;
-const int KEY_UP_BIT    = 1 << 0;
-const int KEY_DOWN_BIT  = 1 << 1;
-const int KEY_RIGHT_BIT = 1 << 2;
-const int KEY_LEFT_BIT  = 1 << 3;
-
-CClientUI* CClientUI::sm_pUI = NULL;
-
-////////////////////////////////////////////////////////////////////////////////
-// constructor
-////////////////////////////////////////////////////////////////////////////////
-CClientUI::CClientUI()
-{
-       sm_pUI = this;
-       m_isEnd = false;
-
-       m_CriticalSectionOfEvent = createCriticalSectionID();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// destructor
-////////////////////////////////////////////////////////////////////////////////
-CClientUI::~CClientUI()
-{
-       deleteCriticalSectionID(m_CriticalSectionOfEvent);
-       uninitialize();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \89æ\96Ê\82ð\95`\89æ\82·\82é
-////////////////////////////////////////////////////////////////////////////////
-void CClientUI::display()
-{
-       // clear buffer
-       glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
-       // initialize modelview matrix
-       glLoadIdentity();
-
-       // \8dÀ\95W\8cn\82Ì\92è\8b`
-       // x-y\95½\96Ê\82ð\92n\96Ê
-       // z = 0\82ð\95W\8d\820
-
-       // set look at matrix
-       // \8c»\8fó\82Í\8fã\82©\82ç\8e\8b\93_\81i\8fã\8bó5m\81j\82Æ\82·\82é
-       gluLookAt(
-               0, 0, 5, // \8e\8b\93_\82Ì\88Ê\92u
-               0, 0, 0,  // \8e\8b\93_\82Ì\96Ú\95W\92n\93_
-               0, 1, 0   // \93ª\82Ì\8cü\82«
-       );
-
-       GLfloat position[] = {-1.0, 1.0, 1.0, 0.0};
-       glLightfv(GL_LIGHT0, GL_POSITION, position);
-
-       // \83A\83o\83^\81[\95`\89æ
-       // \8aÂ\8b«\90Ý\92è
-       GLfloat a_AmbientDiffuse[] = {1.0, 0.0, 0.0, 1.0};
-       GLfloat a_Specular[] = {1.0, 1.0, 1.0, 1.0};
-       GLfloat a_Shininess[] = {20.0};
-       glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, a_AmbientDiffuse);
-       glMaterialfv(GL_FRONT, GL_SPECULAR, a_Specular);
-       glMaterialfv(GL_FRONT, GL_SHININESS, a_Shininess);
-       // set avatar color to white
-       glColor3f(1.0, 1.0, 1.0);
-
-
-       const AvatarInformationList* a_pAvatarInformations = sm_pUI->m_pModel->getAvatarInformationList();
-       for(AvatarInformationList::const_iterator p = a_pAvatarInformations->begin(); p != a_pAvatarInformations->end(); p++){
-               glPushMatrix();
-               {
-                       glTranslated(p->m_Position[0], p->m_Position[1], p->m_Position[2]);
-                       glutSolidSphere(p->m_Radias, 10, 10);
-                       glBegin(GL_LINES);
-                       {
-                               glVertex3d(0.0, 0.0, 0.0);
-                               glVertex3d(p->m_Direction[0], p->m_Direction[1], p->m_Direction[2]);
-                       }
-                       glEnd();
-               }
-               glPopMatrix();
-       }
-
-       glutSwapBuffers();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \8f\89\8aú\89»\82·\82é
-////////////////////////////////////////////////////////////////////////////////
-void CClientUI::init()
-{
-       // background color is black
-       glClearColor(0.0, 0.0, 0.0, 1.0);
-
-       // \8aÂ\8b«\95Ï\90\94\90Ý\92è
-       GLfloat ambient[] = {0.2, 0.2, 0.2, 1.0};
-       GLfloat diffuse[] = {0.6, 0.6, 0.6, 1.0};
-       GLfloat specular[] = {1.0, 1.0, 1.0, 1.0};
-       GLfloat position[] = {-1.0, 1.0, 1.0, 0.0};
-
-       //glEnable(GL_LIGHTING);
-       glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
-       glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
-       glLightfv(GL_LIGHT0, GL_SPECULAR, specular);
-       glLightfv(GL_LIGHT0, GL_POSITION, position);
-       //glEnable(GL_LIGHT0);
-
-       GLfloat material_ambient_diffuse[] = {1.0, 0.0, 0.0, 1.0};
-       GLfloat material_specular[] = {1.0, 1.0, 1.0, 1.0};
-       GLfloat material_shininess[] = {20.0};
-
-       glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, material_ambient_diffuse);
-       glMaterialfv(GL_FRONT, GL_SPECULAR, material_specular);
-       glMaterialfv(GL_FRONT, GL_SHININESS, material_shininess);
-
-       glEnable(GL_DEPTH_TEST);
-       glEnable(GL_CULL_FACE);
-
-       //glShadeModel(GL_FLAT);
-
-       srand(static_cast<unsigned int>(time(NULL)));
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \88ê\94Ê\83L\81[\93ü\97Í
-////////////////////////////////////////////////////////////////////////////////
-void CClientUI::keyboard(unsigned char in_Key, int in_x, int in_y)
-{
-       switch(in_Key){
-       case 'c':
-               // connect
-               sm_pUI->enterCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);
-               sm_pUI->m_Events.push_back("CONNECT");
-               sm_pUI->leaveCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);
-               break;
-
-       case 'd':
-               // disconnect
-               sm_pUI->enterCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);
-               sm_pUI->m_Events.push_back("DISCONNECT");
-               sm_pUI->leaveCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);
-               break;
-
-       case 'i':
-               // login
-               sm_pUI->enterCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);
-               sm_pUI->m_Events.push_back("LOGIN");
-               sm_pUI->leaveCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);
-               break;
-
-       case 'o':
-               // logout
-               sm_pUI->enterCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);
-               sm_pUI->m_Events.push_back("LOGOUT");
-               sm_pUI->leaveCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);
-               break;
-
-       case 'p':
-               // \8dÀ\95W\8eæ\93¾
-               sm_pUI->enterCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);
-               sm_pUI->m_Events.push_back("POSITION");
-               sm_pUI->leaveCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);
-               break;
-
-
-       case 'q':
-       case 'Q':
-       case '\033':  /* '\033' \82Í ESC \82Ì ASCII \83R\81[\83h */
-               sm_pUI->enterCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);
-               sm_pUI->m_Events.push_back("END");
-               sm_pUI->leaveCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);
-               //exit(0);
-       default:
-               break;
-       }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// down special key
-////////////////////////////////////////////////////////////////////////////////
-void CClientUI::downSpecialKey(int in_Key, int in_x, int in_y)
-{
-       switch(in_Key){
-       case GLUT_KEY_UP:
-               g_KeyStatus |= KEY_UP_BIT;
-               break;
-       case GLUT_KEY_DOWN:
-               g_KeyStatus |= KEY_DOWN_BIT;
-               break;
-       case GLUT_KEY_RIGHT:
-               g_KeyStatus |= KEY_RIGHT_BIT;
-               break;
-       case GLUT_KEY_LEFT:
-               g_KeyStatus |= KEY_LEFT_BIT;
-               break;
-       }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// up special key
-////////////////////////////////////////////////////////////////////////////////
-void CClientUI::upSpecialKey(int in_Key, int in_x, int in_y)
-{
-       switch(in_Key){
-       case GLUT_KEY_UP:
-               g_KeyStatus &= ~KEY_UP_BIT;
-               break;
-       case GLUT_KEY_DOWN:
-               g_KeyStatus &= ~KEY_DOWN_BIT;
-               break;
-       case GLUT_KEY_RIGHT:
-               g_KeyStatus &= ~KEY_RIGHT_BIT;
-               break;
-       case GLUT_KEY_LEFT:
-               g_KeyStatus &= ~KEY_LEFT_BIT;
-               break;
-       }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// timer
-////////////////////////////////////////////////////////////////////////////////
-void CClientUI::timer(int value)
-{
-       // 1\95b\8aÔ\82É60\89ñ\8cÄ\82Ñ\8fo\82³\82ê\82é
-       glutTimerFunc(1000 / 60, timer, 0);
-
-       // \83L\81[\93ü\97Í\82Ì\8fó\91Ô\82É\82æ\82è\83A\83o\83^\81[\81ii = 0\82Ì\82Ý\81j\82ð\93®\82©\82·
-       // \91O\90i
-       if((g_KeyStatus & KEY_UP_BIT) && !(g_KeyStatus & KEY_DOWN_BIT)){
-               sm_pUI->enterCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);
-               sm_pUI->m_Events.push_back("FRONT");
-               sm_pUI->leaveCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);
-       }
-       // \8cã\91Þ
-       else if(!(g_KeyStatus & KEY_UP_BIT) && (g_KeyStatus & KEY_DOWN_BIT)){
-               sm_pUI->enterCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);
-               sm_pUI->m_Events.push_back("BACK");
-               sm_pUI->leaveCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);
-       }
-       // \89E\90ù\89ñ
-       if((g_KeyStatus & KEY_RIGHT_BIT) && !(g_KeyStatus & KEY_LEFT_BIT)){
-               sm_pUI->enterCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);
-               sm_pUI->m_Events.push_back("TURN_RIGHT");
-               sm_pUI->leaveCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);
-       }
-       // \8d\90ù\89ñ
-       else if(!(g_KeyStatus & KEY_RIGHT_BIT) && (g_KeyStatus & KEY_LEFT_BIT)){
-               sm_pUI->enterCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);
-               sm_pUI->m_Events.push_back("TURN_LEFT");
-               sm_pUI->leaveCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);
-       }
-
-       sm_pUI->enterCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);
-       sm_pUI->m_Events.push_back("POSITION");
-       sm_pUI->leaveCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);
-
-
-       glutPostRedisplay();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \83T\83C\83Y\95Ï\8dX
-////////////////////////////////////////////////////////////////////////////////
-void CClientUI::reshape(int w, int h)
-{
-       glViewport(0, 0, (GLsizei) w, (GLsizei) h);
-       glMatrixMode(GL_PROJECTION);
-       glLoadIdentity();
-       if(w <= h){
-               glFrustum(-1.0, 1.0, -1.0 * (GLfloat)h / (GLfloat)w, 1.0 * (GLfloat)h / (GLfloat)w, 1.0, 30.0);
-       }
-       else{
-               glFrustum(-1.0 * (GLfloat)w / (GLfloat)h, 1.0 * (GLfloat)w / (GLfloat)h, -1.0, 1.0, 1.0, 30.0);
-       }
-       glMatrixMode(GL_MODELVIEW);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// start input
-////////////////////////////////////////////////////////////////////////////////
-bool CClientUI::initialize()
-{
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// stop input
-////////////////////////////////////////////////////////////////////////////////
-bool CClientUI::uninitialize()
-{
-       m_isEnd = true;
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// thread loop
-////////////////////////////////////////////////////////////////////////////////
-void CClientUI::run()
-{
-       glutInit(m_pArgc, m_ppArgv);
-       glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE);
-       glutInitWindowSize(512, 512);
-       glutCreateWindow("internetcity");
-       glutDisplayFunc(display);
-       glutKeyboardFunc(keyboard);
-       glutSpecialFunc(downSpecialKey);
-       glutSpecialUpFunc(upSpecialKey);
-       glutTimerFunc(1000 / 60, timer, 0);
-       glutReshapeFunc(reshape);
-       init();
-       glutMainLoop();
-}
-
-
+#include "CClientUI.h"\r
+\r
+#include <iostream>\r
+\r
+#include <Windows.h>\r
+#include <cstdlib>\r
+#include <iostream>\r
+#include <cmath>\r
+#include <time.h>\r
+//#include <GL/glut.h>\r
+#include "glut.h"\r
+\r
+#pragma comment(lib, "ws2_32.lib")\r
+\r
+#ifndef M_PI\r
+#define M_PI 3.14159265357989\r
+#endif // M_PI\r
+\r
+\r
+// key status\r
+long g_KeyStatus = 0;\r
+const int KEY_UP_BIT    = 1 << 0;\r
+const int KEY_DOWN_BIT  = 1 << 1;\r
+const int KEY_RIGHT_BIT = 1 << 2;\r
+const int KEY_LEFT_BIT  = 1 << 3;\r
+\r
+CClientUI* CClientUI::sm_pUI = NULL;\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// constructor\r
+////////////////////////////////////////////////////////////////////////////////\r
+CClientUI::CClientUI()\r
+{\r
+       sm_pUI = this;\r
+       m_isEnd = false;\r
+\r
+       m_CriticalSectionOfEvent = createCriticalSectionID();\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// destructor\r
+////////////////////////////////////////////////////////////////////////////////\r
+CClientUI::~CClientUI()\r
+{\r
+       deleteCriticalSectionID(m_CriticalSectionOfEvent);\r
+       uninitialize();\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \89æ\96Ê\82ð\95`\89æ\82·\82é\r
+////////////////////////////////////////////////////////////////////////////////\r
+void CClientUI::display()\r
+{\r
+       // clear buffer\r
+       glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);\r
+\r
+       // initialize modelview matrix\r
+       glLoadIdentity();\r
+\r
+       // \8dÀ\95W\8cn\82Ì\92è\8b`\r
+       // x-y\95½\96Ê\82ð\92n\96Ê\r
+       // z = 0\82ð\95W\8d\820\r
+\r
+       // set look at matrix\r
+       // \8c»\8fó\82Í\8fã\82©\82ç\8e\8b\93_\81i\8fã\8bó5m\81j\82Æ\82·\82é\r
+       gluLookAt(\r
+               0, 0, 5, // \8e\8b\93_\82Ì\88Ê\92u\r
+               0, 0, 0,  // \8e\8b\93_\82Ì\96Ú\95W\92n\93_\r
+               0, 1, 0   // \93ª\82Ì\8cü\82«\r
+       );\r
+\r
+       GLfloat position[] = {-1.0, 1.0, 1.0, 0.0};\r
+       glLightfv(GL_LIGHT0, GL_POSITION, position);\r
+\r
+       // \83A\83o\83^\81[\95`\89æ\r
+       // \8aÂ\8b«\90Ý\92è\r
+       GLfloat a_AmbientDiffuse[] = {1.0, 0.0, 0.0, 1.0};\r
+       GLfloat a_Specular[] = {1.0, 1.0, 1.0, 1.0};\r
+       GLfloat a_Shininess[] = {20.0};\r
+       glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, a_AmbientDiffuse);\r
+       glMaterialfv(GL_FRONT, GL_SPECULAR, a_Specular);\r
+       glMaterialfv(GL_FRONT, GL_SHININESS, a_Shininess);\r
+       // set avatar color to white\r
+       glColor3f(1.0, 1.0, 1.0);\r
+\r
+\r
+       const AvatarInformationList* a_pAvatarInformations = sm_pUI->m_pModel->getAvatarInformationList();\r
+       for(AvatarInformationList::const_iterator p = a_pAvatarInformations->begin(); p != a_pAvatarInformations->end(); p++){\r
+               glPushMatrix();\r
+               {\r
+                       glTranslated(p->m_Position[0], p->m_Position[1], p->m_Position[2]);\r
+                       glutSolidSphere(p->m_Radias, 10, 10);\r
+                       glBegin(GL_LINES);\r
+                       {\r
+                               glVertex3d(0.0, 0.0, 0.0);\r
+                               glVertex3d(p->m_Direction[0], p->m_Direction[1], p->m_Direction[2]);\r
+                       }\r
+                       glEnd();\r
+               }\r
+               glPopMatrix();\r
+       }\r
+\r
+       glutSwapBuffers();\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \8f\89\8aú\89»\82·\82é\r
+////////////////////////////////////////////////////////////////////////////////\r
+void CClientUI::init()\r
+{\r
+       // background color is black\r
+       glClearColor(0.0, 0.0, 0.0, 1.0);\r
+\r
+       // \8aÂ\8b«\95Ï\90\94\90Ý\92è\r
+       GLfloat ambient[] = {0.2, 0.2, 0.2, 1.0};\r
+       GLfloat diffuse[] = {0.6, 0.6, 0.6, 1.0};\r
+       GLfloat specular[] = {1.0, 1.0, 1.0, 1.0};\r
+       GLfloat position[] = {-1.0, 1.0, 1.0, 0.0};\r
+\r
+       //glEnable(GL_LIGHTING);\r
+       glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);\r
+       glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);\r
+       glLightfv(GL_LIGHT0, GL_SPECULAR, specular);\r
+       glLightfv(GL_LIGHT0, GL_POSITION, position);\r
+       //glEnable(GL_LIGHT0);\r
+\r
+       GLfloat material_ambient_diffuse[] = {1.0, 0.0, 0.0, 1.0};\r
+       GLfloat material_specular[] = {1.0, 1.0, 1.0, 1.0};\r
+       GLfloat material_shininess[] = {20.0};\r
+\r
+       glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, material_ambient_diffuse);\r
+       glMaterialfv(GL_FRONT, GL_SPECULAR, material_specular);\r
+       glMaterialfv(GL_FRONT, GL_SHININESS, material_shininess);\r
+\r
+       glEnable(GL_DEPTH_TEST);\r
+       glEnable(GL_CULL_FACE);\r
+\r
+       //glShadeModel(GL_FLAT);\r
+\r
+       srand(static_cast<unsigned int>(time(NULL)));\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \88ê\94Ê\83L\81[\93ü\97Í\r
+////////////////////////////////////////////////////////////////////////////////\r
+void CClientUI::keyboard(unsigned char in_Key, int in_x, int in_y)\r
+{\r
+       switch(in_Key){\r
+       case 'c':\r
+               // connect\r
+               sm_pUI->enterCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);\r
+               sm_pUI->m_Events.push_back("CONNECT");\r
+               sm_pUI->leaveCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);\r
+               break;\r
+\r
+       case 'd':\r
+               // disconnect\r
+               sm_pUI->enterCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);\r
+               sm_pUI->m_Events.push_back("DISCONNECT");\r
+               sm_pUI->leaveCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);\r
+               break;\r
+\r
+       case 'i':\r
+               // login\r
+               sm_pUI->enterCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);\r
+               sm_pUI->m_Events.push_back("LOGIN");\r
+               sm_pUI->leaveCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);\r
+               break;\r
+\r
+       case 'o':\r
+               // logout\r
+               sm_pUI->enterCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);\r
+               sm_pUI->m_Events.push_back("LOGOUT");\r
+               sm_pUI->leaveCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);\r
+               break;\r
+\r
+       case 'p':\r
+               // \8dÀ\95W\8eæ\93¾\r
+               sm_pUI->enterCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);\r
+               sm_pUI->m_Events.push_back("POSITION");\r
+               sm_pUI->leaveCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);\r
+               break;\r
+\r
+\r
+       case 'q':\r
+       case 'Q':\r
+       case '\033':  /* '\033' \82Í ESC \82Ì ASCII \83R\81[\83h */\r
+               sm_pUI->enterCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);\r
+               sm_pUI->m_Events.push_back("END");\r
+               sm_pUI->leaveCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);\r
+               //exit(0);\r
+       default:\r
+               break;\r
+       }\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// down special key\r
+////////////////////////////////////////////////////////////////////////////////\r
+void CClientUI::downSpecialKey(int in_Key, int in_x, int in_y)\r
+{\r
+       switch(in_Key){\r
+       case GLUT_KEY_UP:\r
+               g_KeyStatus |= KEY_UP_BIT;\r
+               break;\r
+       case GLUT_KEY_DOWN:\r
+               g_KeyStatus |= KEY_DOWN_BIT;\r
+               break;\r
+       case GLUT_KEY_RIGHT:\r
+               g_KeyStatus |= KEY_RIGHT_BIT;\r
+               break;\r
+       case GLUT_KEY_LEFT:\r
+               g_KeyStatus |= KEY_LEFT_BIT;\r
+               break;\r
+       }\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// up special key\r
+////////////////////////////////////////////////////////////////////////////////\r
+void CClientUI::upSpecialKey(int in_Key, int in_x, int in_y)\r
+{\r
+       switch(in_Key){\r
+       case GLUT_KEY_UP:\r
+               g_KeyStatus &= ~KEY_UP_BIT;\r
+               break;\r
+       case GLUT_KEY_DOWN:\r
+               g_KeyStatus &= ~KEY_DOWN_BIT;\r
+               break;\r
+       case GLUT_KEY_RIGHT:\r
+               g_KeyStatus &= ~KEY_RIGHT_BIT;\r
+               break;\r
+       case GLUT_KEY_LEFT:\r
+               g_KeyStatus &= ~KEY_LEFT_BIT;\r
+               break;\r
+       }\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// timer\r
+////////////////////////////////////////////////////////////////////////////////\r
+void CClientUI::timer(int value)\r
+{\r
+       // 1\95b\8aÔ\82É60\89ñ\8cÄ\82Ñ\8fo\82³\82ê\82é\r
+       glutTimerFunc(1000 / 60, timer, 0);\r
+\r
+       // \83L\81[\93ü\97Í\82Ì\8fó\91Ô\82É\82æ\82è\83A\83o\83^\81[\81ii = 0\82Ì\82Ý\81j\82ð\93®\82©\82·\r
+       // \91O\90i\r
+       if((g_KeyStatus & KEY_UP_BIT) && !(g_KeyStatus & KEY_DOWN_BIT)){\r
+               sm_pUI->enterCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);\r
+               sm_pUI->m_Events.push_back("FRONT");\r
+               sm_pUI->leaveCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);\r
+       }\r
+       // \8cã\91Þ\r
+       else if(!(g_KeyStatus & KEY_UP_BIT) && (g_KeyStatus & KEY_DOWN_BIT)){\r
+               sm_pUI->enterCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);\r
+               sm_pUI->m_Events.push_back("BACK");\r
+               sm_pUI->leaveCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);\r
+       }\r
+       // \89E\90ù\89ñ\r
+       if((g_KeyStatus & KEY_RIGHT_BIT) && !(g_KeyStatus & KEY_LEFT_BIT)){\r
+               sm_pUI->enterCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);\r
+               sm_pUI->m_Events.push_back("TURN_RIGHT");\r
+               sm_pUI->leaveCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);\r
+       }\r
+       // \8d\90ù\89ñ\r
+       else if(!(g_KeyStatus & KEY_RIGHT_BIT) && (g_KeyStatus & KEY_LEFT_BIT)){\r
+               sm_pUI->enterCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);\r
+               sm_pUI->m_Events.push_back("TURN_LEFT");\r
+               sm_pUI->leaveCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);\r
+       }\r
+\r
+       sm_pUI->enterCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);\r
+       sm_pUI->m_Events.push_back("POSITION");\r
+       sm_pUI->leaveCriticalSectionID(sm_pUI->m_CriticalSectionOfEvent);\r
+\r
+\r
+       glutPostRedisplay();\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \83T\83C\83Y\95Ï\8dX\r
+////////////////////////////////////////////////////////////////////////////////\r
+void CClientUI::reshape(int w, int h)\r
+{\r
+       glViewport(0, 0, (GLsizei) w, (GLsizei) h);\r
+       glMatrixMode(GL_PROJECTION);\r
+       glLoadIdentity();\r
+       if(w <= h){\r
+               glFrustum(-1.0, 1.0, -1.0 * (GLfloat)h / (GLfloat)w, 1.0 * (GLfloat)h / (GLfloat)w, 1.0, 30.0);\r
+       }\r
+       else{\r
+               glFrustum(-1.0 * (GLfloat)w / (GLfloat)h, 1.0 * (GLfloat)w / (GLfloat)h, -1.0, 1.0, 1.0, 30.0);\r
+       }\r
+       glMatrixMode(GL_MODELVIEW);\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// start input\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CClientUI::initialize()\r
+{\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// stop input\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CClientUI::uninitialize()\r
+{\r
+       m_isEnd = true;\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// thread loop\r
+////////////////////////////////////////////////////////////////////////////////\r
+void CClientUI::run()\r
+{\r
+       glutInit(m_pArgc, m_ppArgv);\r
+       glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE);\r
+       glutInitWindowSize(512, 512);\r
+       glutCreateWindow("internetcity");\r
+       glutDisplayFunc(display);\r
+       glutKeyboardFunc(keyboard);\r
+       glutSpecialFunc(downSpecialKey);\r
+       glutSpecialUpFunc(upSpecialKey);\r
+       glutTimerFunc(1000 / 60, timer, 0);\r
+       glutReshapeFunc(reshape);\r
+       init();\r
+       glutMainLoop();\r
+}\r
+\r
+\r
index dd4cc32..b98a1af 100644 (file)
-#ifndef INC_CClientUI
-#define INC_CClientUI
-
-// \83C\83\93\83N\83\8b\81[\83h\82Í\95K\82¸\95K\97v\82È\95¨\82¾\82¯
-// \93à\95\94\82Å\97\98\97p\82·\82é\82¾\82¯\82Ì\95¨\82Í\83\\81[\83X\82É\8bL\8fq
-#include "../../common/CThread.h"
-#include "CClientModel.h"
-#include <list>
-#include <string>
-
-typedef std::string ClientInputEvent;
-
-// \8aÖ\90\94\96¼\82Í\83\8d\81[\83\8f\83L\83\83\83\81\83\8b\83P\81[\83X\82Æ\82·\82é
-
-////////////////////////////////////////////////////////////////////////////////
-// CClientUI
-////////////////////////////////////////////////////////////////////////////////
-class CClientUI : public CThread
-{
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83\81\83\93\83o\95Ï\90\94
-       ////////////////////////////////////////////////////////////////////////////////
-private:
-       static CClientUI* sm_pUI;
-       std::list<ClientInputEvent> m_Events;
-       bool m_isEnd;
-       int* m_pArgc;
-       char** m_ppArgv;
-
-       CClientModel* m_pModel;
-
-       CriticalSectionID m_CriticalSectionOfEvent;
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83R\83\93\83X\83g\83\89\83N\83^
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       CClientUI();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83f\83X\83g\83\89\83N\83^
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       ~CClientUI();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94
-       ////////////////////////////////////////////////////////////////////////////////
-       static void display();
-       void init();
-       static void keyboard(unsigned char in_Key, int in_x, int in_y);
-       static void downSpecialKey(int in_Key, int in_x, int in_y);
-       static void upSpecialKey(int in_Key, int in_x, int in_y);
-       static void timer(int value);
-       static void reshape(int w, int h);
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \91\80\8dì\83\81\83\\83b\83h
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       // start input
-       bool initialize();
-       // stop input
-       bool uninitialize();
-       // thread loop
-       void run();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \91®\90«\83\81\83\\83b\83h
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       void setArgement(int* in_pArgc, char** in_ppArgv)
-       {
-               m_pArgc = in_pArgc;
-               m_ppArgv = in_ppArgv;
-       }
-
-       ClientInputEvent getEvent()
-       {
-               enterCriticalSectionID(m_CriticalSectionOfEvent);
-               ClientInputEvent temp = m_Events.front();
-               m_Events.pop_front();
-               leaveCriticalSectionID(m_CriticalSectionOfEvent);
-               return temp;
-       }
-
-       void setModel(CClientModel* io_pModel)
-       {
-               m_pModel = io_pModel;
-       }
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83C\83e\83\8c\81[\83V\83\87\83\93
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \8fó\91Ô
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       bool existEvent()
-       {
-               return !m_Events.empty();
-       }
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \89\89\8eZ\8eq
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \8f\83\90\88\89¼\91z\8aÖ\90\94\81A\92è\8b`\82Ì\82Ý\81i\94ñ\8eÀ\91\95\92ñ\8b\9f\81j
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \93à\95\94\83N\83\89\83X
-       ////////////////////////////////////////////////////////////////////////////////
-
-
-};
-
-#endif //INC_CClientUI
+#ifndef INC_CClientUI\r
+#define INC_CClientUI\r
+\r
+// \83C\83\93\83N\83\8b\81[\83h\82Í\95K\82¸\95K\97v\82È\95¨\82¾\82¯\r
+// \93à\95\94\82Å\97\98\97p\82·\82é\82¾\82¯\82Ì\95¨\82Í\83\\81[\83X\82É\8bL\8fq\r
+#include "../../common/CThread.h"\r
+#include "CClientModel.h"\r
+#include <list>\r
+#include <string>\r
+\r
+typedef std::string ClientInputEvent;\r
+\r
+// \8aÖ\90\94\96¼\82Í\83\8d\81[\83\8f\83L\83\83\83\81\83\8b\83P\81[\83X\82Æ\82·\82é\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// CClientUI\r
+////////////////////////////////////////////////////////////////////////////////\r
+class CClientUI : public CThread\r
+{\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83\81\83\93\83o\95Ï\90\94\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+private:\r
+       static CClientUI* sm_pUI;\r
+       std::list<ClientInputEvent> m_Events;\r
+       bool m_isEnd;\r
+       int* m_pArgc;\r
+       char** m_ppArgv;\r
+\r
+       CClientModel* m_pModel;\r
+\r
+       CriticalSectionID m_CriticalSectionOfEvent;\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83R\83\93\83X\83g\83\89\83N\83^\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       CClientUI();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83f\83X\83g\83\89\83N\83^\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       ~CClientUI();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       static void display();\r
+       void init();\r
+       static void keyboard(unsigned char in_Key, int in_x, int in_y);\r
+       static void downSpecialKey(int in_Key, int in_x, int in_y);\r
+       static void upSpecialKey(int in_Key, int in_x, int in_y);\r
+       static void timer(int value);\r
+       static void reshape(int w, int h);\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \91\80\8dì\83\81\83\\83b\83h\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       // start input\r
+       bool initialize();\r
+       // stop input\r
+       bool uninitialize();\r
+       // thread loop\r
+       void run();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \91®\90«\83\81\83\\83b\83h\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       void setArgement(int* in_pArgc, char** in_ppArgv)\r
+       {\r
+               m_pArgc = in_pArgc;\r
+               m_ppArgv = in_ppArgv;\r
+       }\r
+\r
+       ClientInputEvent getEvent()\r
+       {\r
+               enterCriticalSectionID(m_CriticalSectionOfEvent);\r
+               ClientInputEvent temp = m_Events.front();\r
+               m_Events.pop_front();\r
+               leaveCriticalSectionID(m_CriticalSectionOfEvent);\r
+               return temp;\r
+       }\r
+\r
+       void setModel(CClientModel* io_pModel)\r
+       {\r
+               m_pModel = io_pModel;\r
+       }\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83C\83e\83\8c\81[\83V\83\87\83\93\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \8fó\91Ô\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       bool existEvent()\r
+       {\r
+               return !m_Events.empty();\r
+       }\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \89\89\8eZ\8eq\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \8f\83\90\88\89¼\91z\8aÖ\90\94\81A\92è\8b`\82Ì\82Ý\81i\94ñ\8eÀ\91\95\92ñ\8b\9f\81j\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \93à\95\94\83N\83\89\83X\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+\r
+\r
+};\r
+\r
+#endif //INC_CClientUI\r
index 69e8776..4a34c05 100644 (file)
@@ -1,58 +1,58 @@
-// \8b\9e
-
-#include "../../common/Environment.h"
-
-#ifdef WIN32
-       //#pragma comment(linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"")
-#endif // WIN32
-
-// \92Ê\90M\82É\82Â\82¢\82Ä
-// \89¹\90º\82ÍRTP\82ð\8eg\82Á\82Ä\92Ê\90M\82ð\8ds\82¢\82½\82¢\82ª\81A\8c»\8dÝ\83\89\83C\83u\83\89\83\8a\82Í\92²\8d¸\92\86\82Å\82 \82é\81B
-// \82³\82ç\82É\81A\83R\83}\83\93\83h\82Æ\89¹\90º\82Ì\90Ø\82è\95ª\82¯\82â\93¯\8aú\82à\8c»\8dÝ\8c\9f\93¢\92\86\82Å\82 \82é\81B
-// \82æ\82Á\82Ä\81A\8c»\92i\8aK\82Å\82Í\83R\83}\83\93\83h\82à\89¹\90º\82à\82·\82×\82ÄTCP\82ð\8eg\97p\82µ\82Ä\92Ê\90M\82ð\8ds\82¤\81B
-// TCP\82ð\8eg\97p\82·\82é\82½\82ß\81A\83R\83}\83\93\83h\82à\89¹\90º\82à\92x\89\84\82ª\90\82\82é\82Æ\8dl\82¦\82ç\82ê\82é\81B
-// \82³\82ç\82É\81A\89¹\90º\82Í\8fí\82É\91\97\90M\82ð\8ds\82Á\82Ä\82¢\82é\82½\82ß\81A\83o\83b\83t\83@\82ª\82 \82é\82ê\82é\82à\82Ì\82Æ\8dl\82¦\82ç\82ê\82é\81B
-// \82»\82Ì\8fê\8d\87\82Í\81A\90V\82µ\82¢\83R\83}\83\93\83h\82â\89¹\90º\82ð\94j\8aü\82·\82é\82±\82Æ\82Å\91Î\89\9e\82ð\8ds\82¤\81B
-// \82±\82ê\82ð\8ds\82¤\82±\82Æ\82É\82æ\82Á\82Ä\81A\83R\83}\83\93\83h\82ª\94½\89\9e\82µ\82È\82©\82Á\82½\82è\81A\89¹\90º\82ª\82Æ\82¬\82ê\82Æ\82¬\82ê\82É\82È\82é\82à\82Ì\82Æ\8dl\82¦\82ç\82ê\82é\81B
-// \82à\82¤\82Ð\82Æ\82Â\82Ì\95û\96@\82Æ\82µ\82Ä\81A\89¹\90º\8fî\95ñ\82ð\82æ\82è\88³\8fk\82µ\83f\81[\83^\97Ê\82ð\8dí\8c¸\82·\82é\95û\96@\82ª\82 \82é\81B
-// \82±\82Ì\95û\96@\82Í\8fã\8bL\82Ì\95û\96@\82ð\8e\8e\82µ\82½\8cã\82É\8ds\82¤\82à\82Ì\82Æ\82·\82é\81B\82Ü\82½\82Í\92¼\90ÚRTP\82ð\8eg\97p\82µ\82½\95û\96@\82ð\8eÀ\91\95\82·\82é\81B
-
-
-// to do
-// \89¹\90º\82Ì\93ü\97Í
-// \89¹\90º\82Ì\8fo\97Í
-// \88³\8fk
-// \89ð\93\9a
-// \83R\83}\83\93\83h\82Ì\93ü\97Í
-// \83T\81[\83o\81[\82Æ\82Ì\92Ê\90M\8b¤\92Ê\8f\88\97\9d
-// \83T\81[\83o\81[\82Ö\82Ì\83\8d\83O\83C\83\93
-// \83T\81[\83o\81[\82Æ\82Ì\83f\81[\83^\82â\82è\8eæ\82è
-
-#include "CClient.h"
-
-#include <iostream>
-
-int main(int argc, char* argv[])
-{
-       char a_LoginName[256];
-       std::cout << "Please, input login name." << std::endl;
-       std::cin >> a_LoginName;
-
-       char a_IpAddress[20];
-       std::cout << "Please, input server ip address." << std::endl;
-       std::cin >> a_IpAddress;
-
-       unsigned short a_PortNumber;
-       std::cout << "Please, input server port number." << std::endl;
-       std::cin >> a_PortNumber;
-
-
-       CClient a_Client;
-       a_Client.initialize();
-       a_Client.setArgement(&argc, argv);
-       a_Client.setLoginName(a_LoginName);
-       a_Client.setServerAddress(a_IpAddress, a_PortNumber);
-       a_Client.mainloop();
-
-       return 0;
-}
+// \8b\9e\r
+\r
+#include "../../common/Environment.h"\r
+\r
+#ifdef WIN32\r
+       //#pragma comment(linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"")\r
+#endif // WIN32\r
+\r
+// \92Ê\90M\82É\82Â\82¢\82Ä\r
+// \89¹\90º\82ÍRTP\82ð\8eg\82Á\82Ä\92Ê\90M\82ð\8ds\82¢\82½\82¢\82ª\81A\8c»\8dÝ\83\89\83C\83u\83\89\83\8a\82Í\92²\8d¸\92\86\82Å\82 \82é\81B\r
+// \82³\82ç\82É\81A\83R\83}\83\93\83h\82Æ\89¹\90º\82Ì\90Ø\82è\95ª\82¯\82â\93¯\8aú\82à\8c»\8dÝ\8c\9f\93¢\92\86\82Å\82 \82é\81B\r
+// \82æ\82Á\82Ä\81A\8c»\92i\8aK\82Å\82Í\83R\83}\83\93\83h\82à\89¹\90º\82à\82·\82×\82ÄTCP\82ð\8eg\97p\82µ\82Ä\92Ê\90M\82ð\8ds\82¤\81B\r
+// TCP\82ð\8eg\97p\82·\82é\82½\82ß\81A\83R\83}\83\93\83h\82à\89¹\90º\82à\92x\89\84\82ª\90\82\82é\82Æ\8dl\82¦\82ç\82ê\82é\81B\r
+// \82³\82ç\82É\81A\89¹\90º\82Í\8fí\82É\91\97\90M\82ð\8ds\82Á\82Ä\82¢\82é\82½\82ß\81A\83o\83b\83t\83@\82ª\82 \82é\82ê\82é\82à\82Ì\82Æ\8dl\82¦\82ç\82ê\82é\81B\r
+// \82»\82Ì\8fê\8d\87\82Í\81A\90V\82µ\82¢\83R\83}\83\93\83h\82â\89¹\90º\82ð\94j\8aü\82·\82é\82±\82Æ\82Å\91Î\89\9e\82ð\8ds\82¤\81B\r
+// \82±\82ê\82ð\8ds\82¤\82±\82Æ\82É\82æ\82Á\82Ä\81A\83R\83}\83\93\83h\82ª\94½\89\9e\82µ\82È\82©\82Á\82½\82è\81A\89¹\90º\82ª\82Æ\82¬\82ê\82Æ\82¬\82ê\82É\82È\82é\82à\82Ì\82Æ\8dl\82¦\82ç\82ê\82é\81B\r
+// \82à\82¤\82Ð\82Æ\82Â\82Ì\95û\96@\82Æ\82µ\82Ä\81A\89¹\90º\8fî\95ñ\82ð\82æ\82è\88³\8fk\82µ\83f\81[\83^\97Ê\82ð\8dí\8c¸\82·\82é\95û\96@\82ª\82 \82é\81B\r
+// \82±\82Ì\95û\96@\82Í\8fã\8bL\82Ì\95û\96@\82ð\8e\8e\82µ\82½\8cã\82É\8ds\82¤\82à\82Ì\82Æ\82·\82é\81B\82Ü\82½\82Í\92¼\90ÚRTP\82ð\8eg\97p\82µ\82½\95û\96@\82ð\8eÀ\91\95\82·\82é\81B\r
+\r
+\r
+// to do\r
+// \89¹\90º\82Ì\93ü\97Í\r
+// \89¹\90º\82Ì\8fo\97Í\r
+// \88³\8fk\r
+// \89ð\93\9a\r
+// \83R\83}\83\93\83h\82Ì\93ü\97Í\r
+// \83T\81[\83o\81[\82Æ\82Ì\92Ê\90M\8b¤\92Ê\8f\88\97\9d\r
+// \83T\81[\83o\81[\82Ö\82Ì\83\8d\83O\83C\83\93\r
+// \83T\81[\83o\81[\82Æ\82Ì\83f\81[\83^\82â\82è\8eæ\82è\r
+\r
+#include "CClient.h"\r
+\r
+#include <iostream>\r
+\r
+int main(int argc, char* argv[])\r
+{\r
+       char a_LoginName[256];\r
+       std::cout << "Please, input login name." << std::endl;\r
+       std::cin >> a_LoginName;\r
+\r
+       char a_IpAddress[20];\r
+       std::cout << "Please, input server ip address." << std::endl;\r
+       std::cin >> a_IpAddress;\r
+\r
+       unsigned short a_PortNumber;\r
+       std::cout << "Please, input server port number." << std::endl;\r
+       std::cin >> a_PortNumber;\r
+\r
+\r
+       CClient a_Client;\r
+       a_Client.initialize();\r
+       a_Client.setArgement(&argc, argv);\r
+       a_Client.setLoginName(a_LoginName);\r
+       a_Client.setServerAddress(a_IpAddress, a_PortNumber);\r
+       a_Client.mainloop();\r
+\r
+       return 0;\r
+}\r
index 254e4b7..90ae7a4 100644 (file)
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup Label="ProjectConfigurations">
-    <ProjectConfiguration Include="Debug|Win32">
-      <Configuration>Debug</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-    <ProjectConfiguration Include="Release|Win32">
-      <Configuration>Release</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-  </ItemGroup>
-  <PropertyGroup Label="Globals">
-    <ProjectGuid>{B25CF9CE-B08B-4647-A84F-C5B9B13D42AB}</ProjectGuid>
-    <Keyword>Win32Proj</Keyword>
-    <RootNamespace>vc2010_client</RootNamespace>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
-    <ConfigurationType>Application</ConfigurationType>
-    <UseDebugLibraries>true</UseDebugLibraries>
-    <CharacterSet>Unicode</CharacterSet>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
-    <ConfigurationType>Application</ConfigurationType>
-    <UseDebugLibraries>false</UseDebugLibraries>
-    <WholeProgramOptimization>true</WholeProgramOptimization>
-    <CharacterSet>Unicode</CharacterSet>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
-  <ImportGroup Label="ExtensionSettings">
-  </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <PropertyGroup Label="UserMacros" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <LinkIncremental>true</LinkIncremental>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <LinkIncremental>false</LinkIncremental>
-  </PropertyGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <ClCompile>
-      <PrecompiledHeader>
-      </PrecompiledHeader>
-      <WarningLevel>Level3</WarningLevel>
-      <Optimization>Disabled</Optimization>
-      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>..\..\..\speex-1.2beta3-win32\include</AdditionalIncludeDirectories>
-    </ClCompile>
-    <Link>
-      <SubSystem>Console</SubSystem>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalLibraryDirectories>..\..\..\speex-1.2beta3-win32\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
-      <PrecompiledHeader>
-      </PrecompiledHeader>
-      <Optimization>MaxSpeed</Optimization>
-      <FunctionLevelLinking>true</FunctionLevelLinking>
-      <IntrinsicFunctions>true</IntrinsicFunctions>
-      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-    </ClCompile>
-    <Link>
-      <SubSystem>Console</SubSystem>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <EnableCOMDATFolding>true</EnableCOMDATFolding>
-      <OptimizeReferences>true</OptimizeReferences>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemGroup>
-    <ClCompile Include="..\..\common\CClientConnection.cpp" />
-    <ClCompile Include="..\..\common\CInputWave.cpp" />
-    <ClCompile Include="..\..\common\COutputWave.cpp" />
-    <ClCompile Include="..\..\common\CSocket.cpp" />
-    <ClCompile Include="..\..\common\CThread.cpp" />
-    <ClCompile Include="CClient.cpp" />
-    <ClCompile Include="CClientModel.cpp" />
-    <ClCompile Include="CClientUI.cpp" />
-    <ClCompile Include="main.cpp" />
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="..\..\common\CClientConnection.h" />
-    <ClInclude Include="..\..\common\CInputWave.h" />
-    <ClInclude Include="..\..\common\COutputWave.h" />
-    <ClInclude Include="..\..\common\CRingBuffer.h" />
-    <ClInclude Include="..\..\common\CSocket.h" />
-    <ClInclude Include="..\..\common\CThread.h" />
-    <ClInclude Include="..\..\common\CWaveData.h" />
-    <ClInclude Include="..\..\common\Data.h" />
-    <ClInclude Include="..\..\common\Environment.h" />
-    <ClInclude Include="CClient.h" />
-    <ClInclude Include="CClientModel.h" />
-    <ClInclude Include="CClientUI.h" />
-  </ItemGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
-  <ImportGroup Label="ExtensionTargets">
-  </ImportGroup>
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <ItemGroup Label="ProjectConfigurations">\r
+    <ProjectConfiguration Include="Debug|Win32">\r
+      <Configuration>Debug</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Release|Win32">\r
+      <Configuration>Release</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+  </ItemGroup>\r
+  <PropertyGroup Label="Globals">\r
+    <ProjectGuid>{B25CF9CE-B08B-4647-A84F-C5B9B13D42AB}</ProjectGuid>\r
+    <Keyword>Win32Proj</Keyword>\r
+    <RootNamespace>vc2010_client</RootNamespace>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>true</UseDebugLibraries>\r
+    <CharacterSet>Unicode</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>false</UseDebugLibraries>\r
+    <WholeProgramOptimization>true</WholeProgramOptimization>\r
+    <CharacterSet>Unicode</CharacterSet>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\r
+  <ImportGroup Label="ExtensionSettings">\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <PropertyGroup Label="UserMacros" />\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <LinkIncremental>true</LinkIncremental>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <LinkIncremental>false</LinkIncremental>\r
+  </PropertyGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <ClCompile>\r
+      <PrecompiledHeader>\r
+      </PrecompiledHeader>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <Optimization>Disabled</Optimization>\r
+      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <AdditionalIncludeDirectories>..\..\..\speex-1.2beta3-win32\include</AdditionalIncludeDirectories>\r
+    </ClCompile>\r
+    <Link>\r
+      <SubSystem>Console</SubSystem>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+      <AdditionalLibraryDirectories>..\..\..\speex-1.2beta3-win32\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <ClCompile>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <PrecompiledHeader>\r
+      </PrecompiledHeader>\r
+      <Optimization>MaxSpeed</Optimization>\r
+      <FunctionLevelLinking>true</FunctionLevelLinking>\r
+      <IntrinsicFunctions>true</IntrinsicFunctions>\r
+      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+    </ClCompile>\r
+    <Link>\r
+      <SubSystem>Console</SubSystem>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
+      <OptimizeReferences>true</OptimizeReferences>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemGroup>\r
+    <ClCompile Include="..\..\common\CClientConnection.cpp" />\r
+    <ClCompile Include="..\..\common\CInputWave.cpp" />\r
+    <ClCompile Include="..\..\common\COutputWave.cpp" />\r
+    <ClCompile Include="..\..\common\CSocket.cpp" />\r
+    <ClCompile Include="..\..\common\CThread.cpp" />\r
+    <ClCompile Include="CClient.cpp" />\r
+    <ClCompile Include="CClientModel.cpp" />\r
+    <ClCompile Include="CClientUI.cpp" />\r
+    <ClCompile Include="main.cpp" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClInclude Include="..\..\common\CClientConnection.h" />\r
+    <ClInclude Include="..\..\common\CInputWave.h" />\r
+    <ClInclude Include="..\..\common\COutputWave.h" />\r
+    <ClInclude Include="..\..\common\CRingBuffer.h" />\r
+    <ClInclude Include="..\..\common\CSocket.h" />\r
+    <ClInclude Include="..\..\common\CThread.h" />\r
+    <ClInclude Include="..\..\common\CWaveData.h" />\r
+    <ClInclude Include="..\..\common\Data.h" />\r
+    <ClInclude Include="..\..\common\Environment.h" />\r
+    <ClInclude Include="CClient.h" />\r
+    <ClInclude Include="CClientModel.h" />\r
+    <ClInclude Include="CClientUI.h" />\r
+  </ItemGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
+  <ImportGroup Label="ExtensionTargets">\r
+  </ImportGroup>\r
 </Project>
\ No newline at end of file
index b93d070..25d061e 100644 (file)
@@ -1,20 +1,20 @@
-
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual C++ Express 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vc2010_server", "vc2010_server\vc2010_server.vcxproj", "{31F108CA-4A93-4744-AAA5-BF7E33B595AD}"
-EndProject
-Global
-       GlobalSection(SolutionConfigurationPlatforms) = preSolution
-               Debug|Win32 = Debug|Win32
-               Release|Win32 = Release|Win32
-       EndGlobalSection
-       GlobalSection(ProjectConfigurationPlatforms) = postSolution
-               {31F108CA-4A93-4744-AAA5-BF7E33B595AD}.Debug|Win32.ActiveCfg = Debug|Win32
-               {31F108CA-4A93-4744-AAA5-BF7E33B595AD}.Debug|Win32.Build.0 = Debug|Win32
-               {31F108CA-4A93-4744-AAA5-BF7E33B595AD}.Release|Win32.ActiveCfg = Release|Win32
-               {31F108CA-4A93-4744-AAA5-BF7E33B595AD}.Release|Win32.Build.0 = Release|Win32
-       EndGlobalSection
-       GlobalSection(SolutionProperties) = preSolution
-               HideSolutionNode = FALSE
-       EndGlobalSection
-EndGlobal
+\r
+Microsoft Visual Studio Solution File, Format Version 11.00\r
+# Visual C++ Express 2010\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vc2010_server", "vc2010_server\vc2010_server.vcxproj", "{31F108CA-4A93-4744-AAA5-BF7E33B595AD}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|Win32 = Debug|Win32\r
+               Release|Win32 = Release|Win32\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {31F108CA-4A93-4744-AAA5-BF7E33B595AD}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {31F108CA-4A93-4744-AAA5-BF7E33B595AD}.Debug|Win32.Build.0 = Debug|Win32\r
+               {31F108CA-4A93-4744-AAA5-BF7E33B595AD}.Release|Win32.ActiveCfg = Release|Win32\r
+               {31F108CA-4A93-4744-AAA5-BF7E33B595AD}.Release|Win32.Build.0 = Release|Win32\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
index c829d2d..0569266 100644 (file)
@@ -1,54 +1,54 @@
-#include "CServer.h"
-
-#include <iostream>
-
-////////////////////////////////////////////////////////////////////////////////
-// constructor
-////////////////////////////////////////////////////////////////////////////////
-CServer::CServer()
-{
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// destructor
-////////////////////////////////////////////////////////////////////////////////
-CServer::~CServer()
-{
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// initialize
-////////////////////////////////////////////////////////////////////////////////
-bool CServer::initialize()
-{
-       m_Input.initialize();
-       m_Model.initialize();
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// mail loop
-////////////////////////////////////////////////////////////////////////////////
-void CServer::mainloop()
-{
-       // \82Æ\82è\82 \82¦\82¸\96³\8cÀ\83\8b\81[\83v\82É\93ü\82é
-       // q\82Ì\93ü\97Í\82Å\8fI\97¹
-
-
-       std::cout << "start server" << std::endl;
-       std::cout << "input \"END\" to end" << std::endl;
-
-       while(true){
-               if(m_Input.existEvent()){
-                       ServerInputEvent a_Event = m_Input.getEvent();
-                       if(a_Event == "END"){
-                               break;
-                       }
-               }
-               m_Model.process();
-               Sleep(1);
-       }
-
-
-       std::cout << "end server" << std::endl;
-}
+#include "CServer.h"\r
+\r
+#include <iostream>\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// constructor\r
+////////////////////////////////////////////////////////////////////////////////\r
+CServer::CServer()\r
+{\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// destructor\r
+////////////////////////////////////////////////////////////////////////////////\r
+CServer::~CServer()\r
+{\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// initialize\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CServer::initialize()\r
+{\r
+       m_Input.initialize();\r
+       m_Model.initialize();\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// mail loop\r
+////////////////////////////////////////////////////////////////////////////////\r
+void CServer::mainloop()\r
+{\r
+       // \82Æ\82è\82 \82¦\82¸\96³\8cÀ\83\8b\81[\83v\82É\93ü\82é\r
+       // q\82Ì\93ü\97Í\82Å\8fI\97¹\r
+\r
+\r
+       std::cout << "start server" << std::endl;\r
+       std::cout << "input \"END\" to end" << std::endl;\r
+\r
+       while(true){\r
+               if(m_Input.existEvent()){\r
+                       ServerInputEvent a_Event = m_Input.getEvent();\r
+                       if(a_Event == "END"){\r
+                               break;\r
+                       }\r
+               }\r
+               m_Model.process();\r
+               Sleep(1);\r
+       }\r
+\r
+\r
+       std::cout << "end server" << std::endl;\r
+}\r
index 3a6ab5d..74d76a5 100644 (file)
@@ -1,71 +1,71 @@
-#ifndef INC_CServer
-#define INC_CServer
-
-// \83C\83\93\83N\83\8b\81[\83h\82Í\95K\82¸\95K\97v\82È\95¨\82¾\82¯
-// \93à\95\94\82Å\97\98\97p\82·\82é\82¾\82¯\82Ì\95¨\82Í\83\\81[\83X\82É\8bL\8fq
-#include "CServerModel.h"
-#include "CServerInput.h"
-
-// \8aÖ\90\94\96¼\82Í\83\8d\81[\83\8f\83L\83\83\83\81\83\8b\83P\81[\83X\82Æ\82·\82é
-
-////////////////////////////////////////////////////////////////////////////////
-// CServer
-////////////////////////////////////////////////////////////////////////////////
-class CServer
-{
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83\81\83\93\83o\95Ï\90\94
-       ////////////////////////////////////////////////////////////////////////////////
-private:
-       CServerInput m_Input;
-       CServerModel m_Model;
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83R\83\93\83X\83g\83\89\83N\83^
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       CServer();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83f\83X\83g\83\89\83N\83^
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       ~CServer();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \91\80\8dì\83\81\83\\83b\83h
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       // \8f\89\8aú\89»
-       bool initialize();
-       // main loop
-       void mainloop();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \91®\90«\83\81\83\\83b\83h
-       ////////////////////////////////////////////////////////////////////////////////
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83C\83e\83\8c\81[\83V\83\87\83\93
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \8fó\91Ô
-       ////////////////////////////////////////////////////////////////////////////////
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \89\89\8eZ\8eq
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \8f\83\90\88\89¼\91z\8aÖ\90\94\81A\92è\8b`\82Ì\82Ý\81i\94ñ\8eÀ\91\95\92ñ\8b\9f\81j
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \93à\95\94\83N\83\89\83X
-       ////////////////////////////////////////////////////////////////////////////////
-
-
-};
-
-#endif //INC_CServer
+#ifndef INC_CServer\r
+#define INC_CServer\r
+\r
+// \83C\83\93\83N\83\8b\81[\83h\82Í\95K\82¸\95K\97v\82È\95¨\82¾\82¯\r
+// \93à\95\94\82Å\97\98\97p\82·\82é\82¾\82¯\82Ì\95¨\82Í\83\\81[\83X\82É\8bL\8fq\r
+#include "CServerModel.h"\r
+#include "CServerInput.h"\r
+\r
+// \8aÖ\90\94\96¼\82Í\83\8d\81[\83\8f\83L\83\83\83\81\83\8b\83P\81[\83X\82Æ\82·\82é\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// CServer\r
+////////////////////////////////////////////////////////////////////////////////\r
+class CServer\r
+{\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83\81\83\93\83o\95Ï\90\94\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+private:\r
+       CServerInput m_Input;\r
+       CServerModel m_Model;\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83R\83\93\83X\83g\83\89\83N\83^\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       CServer();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83f\83X\83g\83\89\83N\83^\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       ~CServer();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \91\80\8dì\83\81\83\\83b\83h\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       // \8f\89\8aú\89»\r
+       bool initialize();\r
+       // main loop\r
+       void mainloop();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \91®\90«\83\81\83\\83b\83h\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83C\83e\83\8c\81[\83V\83\87\83\93\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \8fó\91Ô\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \89\89\8eZ\8eq\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \8f\83\90\88\89¼\91z\8aÖ\90\94\81A\92è\8b`\82Ì\82Ý\81i\94ñ\8eÀ\91\95\92ñ\8b\9f\81j\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \93à\95\94\83N\83\89\83X\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+\r
+\r
+};\r
+\r
+#endif //INC_CServer\r
index 38453ee..b61956a 100644 (file)
@@ -1,57 +1,57 @@
-#include "CServerInput.h"
-
-#include <iostream>
-
-////////////////////////////////////////////////////////////////////////////////
-// constructor
-////////////////////////////////////////////////////////////////////////////////
-CServerInput::CServerInput()
-{
-       m_CriticalSectionOfEvent = createCriticalSectionID();
-       m_isEnd = false;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// destructor
-////////////////////////////////////////////////////////////////////////////////
-CServerInput::~CServerInput()
-{
-       deleteCriticalSectionID(m_CriticalSectionOfEvent);
-       uninitialize();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// start input
-////////////////////////////////////////////////////////////////////////////////
-bool CServerInput::initialize()
-{
-       start();
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// stop input
-////////////////////////////////////////////////////////////////////////////////
-bool CServerInput::uninitialize()
-{
-       m_isEnd = true;
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// thread loop
-////////////////////////////////////////////////////////////////////////////////
-void CServerInput::run()
-{
-       while(true){
-               if(m_isEnd){
-                       break;
-               }
-
-               std::string input;
-               std::cin >> input;
-               enterCriticalSectionID(m_CriticalSectionOfEvent);
-               m_Events.push_back(input);
-               leaveCriticalSectionID(m_CriticalSectionOfEvent);
-       }
-}
+#include "CServerInput.h"\r
+\r
+#include <iostream>\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// constructor\r
+////////////////////////////////////////////////////////////////////////////////\r
+CServerInput::CServerInput()\r
+{\r
+       m_CriticalSectionOfEvent = createCriticalSectionID();\r
+       m_isEnd = false;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// destructor\r
+////////////////////////////////////////////////////////////////////////////////\r
+CServerInput::~CServerInput()\r
+{\r
+       deleteCriticalSectionID(m_CriticalSectionOfEvent);\r
+       uninitialize();\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// start input\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CServerInput::initialize()\r
+{\r
+       start();\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// stop input\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CServerInput::uninitialize()\r
+{\r
+       m_isEnd = true;\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// thread loop\r
+////////////////////////////////////////////////////////////////////////////////\r
+void CServerInput::run()\r
+{\r
+       while(true){\r
+               if(m_isEnd){\r
+                       break;\r
+               }\r
+\r
+               std::string input;\r
+               std::cin >> input;\r
+               enterCriticalSectionID(m_CriticalSectionOfEvent);\r
+               m_Events.push_back(input);\r
+               leaveCriticalSectionID(m_CriticalSectionOfEvent);\r
+       }\r
+}\r
index 6ba08fd..ff1c01e 100644 (file)
@@ -1,92 +1,92 @@
-#ifndef INC_CServerInput
-#define INC_CServerInput
-
-// \83C\83\93\83N\83\8b\81[\83h\82Í\95K\82¸\95K\97v\82È\95¨\82¾\82¯
-// \93à\95\94\82Å\97\98\97p\82·\82é\82¾\82¯\82Ì\95¨\82Í\83\\81[\83X\82É\8bL\8fq
-#include "../../common/CThread.h"
-#include <list>
-#include <string>
-
-typedef std::string ServerInputEvent;
-
-// \8aÖ\90\94\96¼\82Í\83\8d\81[\83\8f\83L\83\83\83\81\83\8b\83P\81[\83X\82Æ\82·\82é
-
-////////////////////////////////////////////////////////////////////////////////
-// CServerInput
-////////////////////////////////////////////////////////////////////////////////
-class CServerInput : public CThread
-{
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83\81\83\93\83o\95Ï\90\94
-       ////////////////////////////////////////////////////////////////////////////////
-private:
-       std::list<ServerInputEvent> m_Events;
-       bool m_isEnd;
-
-       CriticalSectionID m_CriticalSectionOfEvent;
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83R\83\93\83X\83g\83\89\83N\83^
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       CServerInput();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83f\83X\83g\83\89\83N\83^
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       ~CServerInput();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \91\80\8dì\83\81\83\\83b\83h
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       // start input
-       bool initialize();
-       // stop input
-       bool uninitialize();
-       // thread loop
-       void run();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \91®\90«\83\81\83\\83b\83h
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       ServerInputEvent getEvent()
-       {
-               enterCriticalSectionID(m_CriticalSectionOfEvent);
-               ServerInputEvent temp = m_Events.front();
-               m_Events.pop_front();
-               leaveCriticalSectionID(m_CriticalSectionOfEvent);
-               return temp;
-       }
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83C\83e\83\8c\81[\83V\83\87\83\93
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \8fó\91Ô
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       bool existEvent()
-       {
-               return !m_Events.empty();
-       }
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \89\89\8eZ\8eq
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \8f\83\90\88\89¼\91z\8aÖ\90\94\81A\92è\8b`\82Ì\82Ý\81i\94ñ\8eÀ\91\95\92ñ\8b\9f\81j
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \93à\95\94\83N\83\89\83X
-       ////////////////////////////////////////////////////////////////////////////////
-
-
-};
-
-#endif //INC_CServerInput
+#ifndef INC_CServerInput\r
+#define INC_CServerInput\r
+\r
+// \83C\83\93\83N\83\8b\81[\83h\82Í\95K\82¸\95K\97v\82È\95¨\82¾\82¯\r
+// \93à\95\94\82Å\97\98\97p\82·\82é\82¾\82¯\82Ì\95¨\82Í\83\\81[\83X\82É\8bL\8fq\r
+#include "../../common/CThread.h"\r
+#include <list>\r
+#include <string>\r
+\r
+typedef std::string ServerInputEvent;\r
+\r
+// \8aÖ\90\94\96¼\82Í\83\8d\81[\83\8f\83L\83\83\83\81\83\8b\83P\81[\83X\82Æ\82·\82é\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// CServerInput\r
+////////////////////////////////////////////////////////////////////////////////\r
+class CServerInput : public CThread\r
+{\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83\81\83\93\83o\95Ï\90\94\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+private:\r
+       std::list<ServerInputEvent> m_Events;\r
+       bool m_isEnd;\r
+\r
+       CriticalSectionID m_CriticalSectionOfEvent;\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83R\83\93\83X\83g\83\89\83N\83^\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       CServerInput();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83f\83X\83g\83\89\83N\83^\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       ~CServerInput();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \91\80\8dì\83\81\83\\83b\83h\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       // start input\r
+       bool initialize();\r
+       // stop input\r
+       bool uninitialize();\r
+       // thread loop\r
+       void run();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \91®\90«\83\81\83\\83b\83h\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       ServerInputEvent getEvent()\r
+       {\r
+               enterCriticalSectionID(m_CriticalSectionOfEvent);\r
+               ServerInputEvent temp = m_Events.front();\r
+               m_Events.pop_front();\r
+               leaveCriticalSectionID(m_CriticalSectionOfEvent);\r
+               return temp;\r
+       }\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83C\83e\83\8c\81[\83V\83\87\83\93\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \8fó\91Ô\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       bool existEvent()\r
+       {\r
+               return !m_Events.empty();\r
+       }\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \89\89\8eZ\8eq\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \8f\83\90\88\89¼\91z\8aÖ\90\94\81A\92è\8b`\82Ì\82Ý\81i\94ñ\8eÀ\91\95\92ñ\8b\9f\81j\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \93à\95\94\83N\83\89\83X\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+\r
+\r
+};\r
+\r
+#endif //INC_CServerInput\r
index c24eeca..bdee255 100644 (file)
-#include "../../common/Environment.h"
-#include "CServerModel.h"
-
-#include <iostream>
-
-////////////////////////////////////////////////////////////////////////////////
-// constructor
-////////////////////////////////////////////////////////////////////////////////
-CServerModel::CServerModel()
-{
-       initializeSpeex(&m_SpeexData);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// destructor
-////////////////////////////////////////////////////////////////////////////////
-CServerModel::~CServerModel()
-{
-       for(size_t i = 0; i < m_Connections.size(); i++){
-               delete m_Connections[i].m_pConnection;
-       }
-       for(AvatarInformationList::iterator p = m_AvatarInformations.begin(); p != m_AvatarInformations.end(); p++){
-               delete *p;
-       }
-       uninitializeSpeex(&m_SpeexData);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// initialize
-////////////////////////////////////////////////////////////////////////////////
-bool CServerModel::initialize()
-{
-       m_ServerSocket.initialize();
-       m_ServerSocket.openPort();
-
-       m_Connections.resize(MAX_CONNECTION_NUMBER);
-       for(size_t i = 0; i < m_Connections.size(); i++){
-               ConnectionTuple temp;
-               temp.m_pConnection = new CServerConnection();
-               temp.m_pConnection->initialize();
-               m_ServerSocket.accept(temp.m_pConnection);
-               temp.m_pAvatarInformation = NULL;
-               m_Connections[i] = temp;
-       }
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// initialize of speex
-////////////////////////////////////////////////////////////////////////////////
-bool CServerModel::initializeSpeex(SpeexData* io_pSpeexData)
-{
-       io_pSpeexData->st = speex_encoder_init(speex_lib_get_mode(SPEEX_MODEID_NB));
-       io_pSpeexData->dec = speex_decoder_init(speex_lib_get_mode(SPEEX_MODEID_NB));
-
-       /* BEGIN: You probably don't need the following in a real application */
-#if 0
-       callback.callback_id = SPEEX_INBAND_CHAR;
-       callback.func = speex_std_char_handler;
-       callback.data = stderr;
-       speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);
-
-       callback.callback_id = SPEEX_INBAND_MODE_REQUEST;
-       callback.func = speex_std_mode_request_handler;
-       callback.data = st;
-       speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);
-#endif
-       /* END of unnecessary stuff */
-
-       spx_int32_t tmp;
-       tmp=1;
-       speex_decoder_ctl(io_pSpeexData->dec, SPEEX_SET_ENH, &tmp);
-       tmp=0;
-       speex_encoder_ctl(io_pSpeexData->st, SPEEX_SET_VBR, &tmp);
-       tmp=8;
-       speex_encoder_ctl(io_pSpeexData->st, SPEEX_SET_QUALITY, &tmp);
-       /*
-       tmp=1;
-       speex_encoder_ctl(st, SPEEX_SET_COMPLEXITY, &tmp);
-       */
-       tmp = 8000;
-       //speex_encoder_ctl(st, SPEEX_SET_SAMPLING_RATE, &tmp);
-       //speex_decoder_ctl(dec, SPEEX_SET_SAMPLING_RATE, &tmp);
-       //tmp = 8000;
-       //speex_encoder_ctl(st, SPEEX_SET_BITRATE, &tmp);
-
-       spx_int32_t frame_size;
-       speex_encoder_ctl(io_pSpeexData->st, SPEEX_GET_FRAME_SIZE, &frame_size);
-
-       /* Turn this off if you want to measure SNR (on by default) */
-       /*
-       tmp=1;
-       speex_encoder_ctl(st, SPEEX_SET_HIGHPASS, &tmp);
-       speex_decoder_ctl(dec, SPEEX_SET_HIGHPASS, &tmp);
-       */
-
-       speex_encoder_ctl(io_pSpeexData->st, SPEEX_GET_LOOKAHEAD, &io_pSpeexData->skip_group_delay);
-       speex_decoder_ctl(io_pSpeexData->dec, SPEEX_GET_LOOKAHEAD, &tmp);
-       io_pSpeexData->skip_group_delay += tmp;
-
-       speex_bits_init(&io_pSpeexData->bits);
-
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// uninitialize of speex
-////////////////////////////////////////////////////////////////////////////////
-bool CServerModel::uninitializeSpeex(SpeexData* io_pSpeexData)
-{
-       speex_encoder_destroy(io_pSpeexData->st);
-       speex_decoder_destroy(io_pSpeexData->dec);
-       speex_bits_destroy(&io_pSpeexData->bits);
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \8f\88\97\9d
-////////////////////////////////////////////////////////////////////////////////
-bool CServerModel::process()
-{
-       // \92Ê\90M\83N\83\89\83X\82©\82ç\83f\81[\83^\8eæ\93¾
-       for(ConnectionVector::iterator p = m_Connections.begin(); p != m_Connections.end(); p++){
-               CommunicationData* a_pData;
-               if(p->m_pConnection->receive(&a_pData)){
-                       // \83\8d\83O\83C\83\93\8f\88\97\9d\81i\83Z\83b\83V\83\87\83\93\82Æ\83\8d\83O\83C\83\93\83l\81[\83\80\82Æ\81i\83p\83X\83\8f\81[\83h\81j\82ð\93n\82·\81j
-                       if(a_pData->m_DataType == 'i'){
-                               if(login(p, a_pData->m_Data.m_LoginData.m_Name)){
-                                       std::cout << "login " << a_pData->m_Data.m_LoginData.m_Name << std::endl;
-                               }
-                       }
-                       // \83\8d\83O\83A\83E\83g\8f\88\97\9d
-                       else if(a_pData->m_DataType == 'o'){
-                               logout(p, p->m_pAvatarInformation->m_Name);
-                       }
-                       // \8dÀ\95W\8eæ\93¾
-                       else if(a_pData->m_DataType == 'p'){
-                               requestPosition(p);
-                       }
-                       // \83A\83N\83V\83\87\83\93\83R\83}\83\93\83h\82ð\8f\88\97\9d
-                       else if(a_pData->m_DataType == 'a'){
-                               requestMove(p, a_pData->m_Data.m_ActionCommand.m_CommandType);
-                       }
-                       // \89¹\90º\83f\81[\83^\82ð\8ai\94[\82·\82é
-                       else if(a_pData->m_DataType == 'v' && p->m_pAvatarInformation != NULL){
-                               std::cout << "\8eó\90M" << std::endl;
-                               short out_short[FRAME_SIZE];
-
-                               // \83\8a\83Z\83b\83g
-                               //speex_bits_reset(&m_SpeexData.bits);
-
-                               // \88³\8fk\83r\83b\83g\83X\83g\83\8a\81[\83\80\82ð\83Z\83b\83g\81i\93¯\8e\9e\82É\83\8a\83Z\83b\83g\82³\82ê\82é\81j
-                               speex_bits_read_from(&m_SpeexData.bits, a_pData->m_Data.m_Voice.m_Stream, a_pData->m_Data.m_Voice.m_Length);
-
-                               // \89ð\93\80
-                               speex_decode_int(m_SpeexData.dec, &m_SpeexData.bits, out_short);
-
-                               // Convert 16 -> 8 bits
-                               for(int i = 0; i < FRAME_SIZE; i++){
-                                       p->m_pAvatarInformation->m_Stream[p->m_pAvatarInformation->m_Length] = (out_short[i] ^ 0x8000) >> 8;
-                                       p->m_pAvatarInformation->m_Length++;
-                               }
-
-                               if(a_pData->m_Data.m_Voice.m_isEnd){
-                                       StructWaveBuffer* a_pOutputWaveData = p->m_pAvatarInformation->m_Voice.getWritePointer();
-                                       a_pOutputWaveData->m_pWaveBuffer = p->m_pAvatarInformation->m_Stream;
-                                       a_pOutputWaveData->m_BufferSize = p->m_pAvatarInformation->m_Length;
-                                       a_pOutputWaveData->m_RecorMilliSecond = 100;
-                                       p->m_pAvatarInformation->m_Length = 0;
-                                       p->m_pAvatarInformation->m_Voice.nextWriteBuffer();
-                                       //std::cout << "reset" << std::endl;
-                               }
-                       }
-               }
-       }
-       // \89¹\90º\83f\81[\83^\82ª\82 \82ê\82Î\91\97\90M\82·\82é
-       sendVoice();
-
-       // \89¹\90º\82ð\8d\87\90¬
-       // memo: \93¯\8e\9e\82É\8eó\90M\82µ\82½\89¹\90º\82ð\81A\93¯\8e\9e\8d\8f\82Æ\82µ\82Ä\8d\87\90¬\82·\82é
-       // memo: \88³\8fk\89¹\90º\83f\81[\83^\82Í\95ª\8a\84\82µ\82Ä\91\97\90M\82³\82ê\82é\82½\82ß\81A\82µ\82Î\82ç\82­\82½\82ß\82Ä\82¨\82­\95K\97v\82ª\82 \82é
-       // memo: \82½\82ß\82½\8fê\8d\87\81A\8dÅ\8f\89\82ª\8f­\82µ\92x\82ê\82é\82¾\82¯\82Å\81A\89¹\82ª\82Æ\82¬\82ê\82é\82±\82Æ\82Í\82È\82¢
-       // memo: \82½\82¾\82µ\81A\8e©\95ª\8e©\90M\82Ì\90º\82Í\92x\82ê\82Ä\95·\82±\82¦\82é\82Ì\82Å\81A\8e©\95ª\8e©\90g\82Ì\89¹\82Í\91\97\82è\95Ô\82³\82È\82¢
-       // memo: \82Ü\82½\81A\89¹\90º\82Ì\8d\87\90¬\82Í\8ae\83L\83\83\83\89\83N\83^\81[\81i\83N\83\89\83C\83A\83\93\83g\81j\82²\82Æ\82É\90\90¬\82µ\82È\82¯\82ê\82Î\82È\82ç\82È\82¢
-
-       // \8eæ\93¾\83R\83}\83\93\83h\82É\91Î\82µ\82Ä\83f\81[\83^\91\97\90M
-
-
-       // to do
-       // \89¹\90º\82ð\8d\87\90¬\82·\82é\8fê\8d\87\81A\93¯\82\89¹\82ð\89½\93x\82à\8d\87\90¬\82µ\82È\82¢\82æ\82¤\82É\82·\82é\82½\82ß\81A
-       // \98^\89¹\8e\9e\8d\8f\82â\8eó\90M\8e\9e\8d\8f\82ð\97\98\97p\82µ\82Ä\81A\8f\87\94Ô\82ð\8aÔ\88á\82¦\82È\82¢\82æ\82¤\82µ\82È\82¯\82ê\82Î\82È\82ç\82È\82¢
-
-       // \89¹\8fî\95ñ\82ð\8aÈ\92P\82É\88µ\82¤\82½\82ß\81A\92Ê\90M\83N\83\89\83X\82ð\82à\82¤\8f­\82µ\82Ü\82Æ\82ß\82È\82¯\82ê\82Î\82È\82ç\82È\82¢
-
-       // Model\83N\83\89\83X\82©\82ç\82Í\92Ê\90M\82ð\8ds\82Á\82Ä\82¢\82é\82±\82Æ\82ð\88Ó\8e¯\82µ\82È\82¢\82æ\82¤\82É\82µ\82½\82¢
-
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// login
-////////////////////////////////////////////////////////////////////////////////
-bool CServerModel::login(ConnectionVector::iterator io_ConnectionIterator, const char* in_pLoginName)
-{
-       AvatarInformation* temp = new AvatarInformation;
-       strcpy(temp->m_Name, in_pLoginName);
-       temp->m_Position[0] = 0;
-       temp->m_Position[1] = 0;
-       temp->m_Position[2] = 0;
-       temp->m_Direction[0] = 1;
-       temp->m_Direction[1] = 0;
-       temp->m_Direction[2] = 0;
-       temp->m_Radias = 0.3;
-       // \82 \82Æ\82Å\8fC\90³\95K\90{\81i\83}\83W\83b\83N\83i\83\93\83o\81[\81j
-       temp->m_Voice.allocate(10, 100, 2080);
-       temp->m_Length = 0;
-       m_AvatarInformations.push_back(temp);
-
-       CommunicationData a_SendData;
-       a_SendData.m_DataType = 'i';
-       strcpy(a_SendData.m_Data.m_LoginData.m_Name, in_pLoginName);
-       io_ConnectionIterator->m_pConnection->send(&a_SendData);
-       io_ConnectionIterator->m_pAvatarInformation = temp;
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// logout
-////////////////////////////////////////////////////////////////////////////////
-bool CServerModel::logout(ConnectionVector::iterator io_ConnectionIterator, const char* in_pLoginName)
-{
-       // \96¢\83\8d\83O\83C\83\93
-       if(io_ConnectionIterator->m_pAvatarInformation == NULL){
-               return false;
-       }
-
-       CommunicationData a_SendData;
-       a_SendData.m_DataType = 'o';
-       strcpy(a_SendData.m_Data.m_LoginData.m_Name, in_pLoginName);
-       io_ConnectionIterator->m_pConnection->send(&a_SendData);
-
-       std::cout << "logout " << io_ConnectionIterator->m_pAvatarInformation->m_Name << std::endl;
-
-       // \83A\83o\83^\81[\82ð\8dí\8f\9c\82·\82é
-       for(AvatarInformationList::iterator p = m_AvatarInformations.begin(); p != m_AvatarInformations.end(); p++){
-               if(*p == io_ConnectionIterator->m_pAvatarInformation){
-                       delete *p;
-               }
-               m_AvatarInformations.erase(p);
-               break;
-       }
-       io_ConnectionIterator->m_pAvatarInformation = NULL;
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// position
-////////////////////////////////////////////////////////////////////////////////
-bool CServerModel::requestPosition(ConnectionVector::iterator io_ConnectionIterator)
-{
-       // \96¢\83\8d\83O\83C\83\93
-       if(io_ConnectionIterator->m_pAvatarInformation == NULL){
-               return false;
-       }
-
-       if(!m_AvatarInformations.empty()){
-               for(AvatarInformationList::iterator p = m_AvatarInformations.begin(); p != m_AvatarInformations.end(); p++){
-                       CommunicationData a_SendData;
-                       a_SendData.m_DataType = 'p';
-                       strcpy(a_SendData.m_Data.m_AvatarData.m_Name, (*p)->m_Name);
-                       a_SendData.m_Data.m_AvatarData.m_Position[0] = (*p)->m_Position[0];
-                       a_SendData.m_Data.m_AvatarData.m_Position[1] = (*p)->m_Position[1];
-                       a_SendData.m_Data.m_AvatarData.m_Position[2] = (*p)->m_Position[2];
-                       a_SendData.m_Data.m_AvatarData.m_Direction[0] = (*p)->m_Direction[0];
-                       a_SendData.m_Data.m_AvatarData.m_Direction[1] = (*p)->m_Direction[1];
-                       a_SendData.m_Data.m_AvatarData.m_Direction[2] = (*p)->m_Direction[2];
-                       a_SendData.m_Data.m_AvatarData.m_Radias = (*p)->m_Radias;
-
-                       if(!io_ConnectionIterator->m_pConnection->send(&a_SendData)){
-                               std::cout << "do not send position" << std::endl;
-                       }
-               }
-       }
-       /*
-       else{
-               CommunicationData a_SendData;
-               a_SendBuffer.m_Length = sprintf(a_SendBuffer.m_Buffer, "p;");
-               if(!io_pConnection->send(&a_SendBuffer)){
-                       std::cout << "do not send position" << std::endl;
-               }
-       }
-       */
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// move
-////////////////////////////////////////////////////////////////////////////////
-bool CServerModel::requestMove(ConnectionVector::iterator io_ConnectionIterator, char in_pMoveDirection)
-{
-       const double M_PI = 3.14159265357989;
-       // \90l\82Ì\95à\82­\91¬\93x\82ð1\95b\8aÔ\82É1m\82Æ\82·\82é
-       const double a_VelocityParTimes = 1.0 / 60;
-       // 2\95b\82Å\90U\82è\95Ô\82é\81i180\93x = pi\81j\82Æ\82·\82é\81B
-       const double a_RotateParTimes = M_PI / (2 * 60);
-
-       // \96¢\83\8d\83O\83C\83\93
-       if(io_ConnectionIterator->m_pAvatarInformation == NULL){
-               return false;
-       }
-
-       AvatarInformation* a_pAvatarInformation = io_ConnectionIterator->m_pAvatarInformation;
-
-       if(in_pMoveDirection == 'f'){
-               a_pAvatarInformation->m_Position[0] += a_pAvatarInformation->m_Direction[0] * a_VelocityParTimes;
-               a_pAvatarInformation->m_Position[1] += a_pAvatarInformation->m_Direction[1] * a_VelocityParTimes;
-               a_pAvatarInformation->m_Position[2] += a_pAvatarInformation->m_Direction[2] * a_VelocityParTimes;
-       }
-       // \8cã\95û\82Ö\88Ú\93®
-       else if(in_pMoveDirection == 'b'){
-               a_pAvatarInformation->m_Position[0] -= a_pAvatarInformation->m_Direction[0] * a_VelocityParTimes;
-               a_pAvatarInformation->m_Position[1] -= a_pAvatarInformation->m_Direction[1] * a_VelocityParTimes;
-               a_pAvatarInformation->m_Position[2] -= a_pAvatarInformation->m_Direction[2] * a_VelocityParTimes;
-       }
-       // \89E\90ù\89ñ
-       else if(in_pMoveDirection == 'r'){
-               double x = a_pAvatarInformation->m_Direction[0];
-               double y = a_pAvatarInformation->m_Direction[1];
-               a_pAvatarInformation->m_Direction[0] =  x * cos(a_RotateParTimes) + y * sin(a_RotateParTimes);
-               a_pAvatarInformation->m_Direction[1] = -x * sin(a_RotateParTimes) + y * cos(a_RotateParTimes);
-       }
-       // \8d\90ù\89ñ
-       else if(in_pMoveDirection == 'l'){
-               double x = a_pAvatarInformation->m_Direction[0];
-               double y = a_pAvatarInformation->m_Direction[1];
-               a_pAvatarInformation->m_Direction[0] =  x * cos(a_RotateParTimes) - y * sin(a_RotateParTimes);
-               a_pAvatarInformation->m_Direction[1] =  x * sin(a_RotateParTimes) + y * cos(a_RotateParTimes);
-       }
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// \89¹\90º\91\97\90M
-////////////////////////////////////////////////////////////////////////////////
-bool CServerModel::sendVoice()
-{
-       bool check = false;
-       for(ConnectionVector::iterator p = m_Connections.begin(); p != m_Connections.end(); p++){
-               if(p->m_pAvatarInformation != NULL){
-                       check = true;
-                       StructWaveBuffer* a_pWaveBuffer = p->m_pAvatarInformation->m_Voice.getReadPointer();
-                       if(a_pWaveBuffer == NULL){
-                               // \88ê\82Â\82Å\82à\89¹\90º\83f\81[\83^\82ª\91\8dÝ\82µ\82È\82¯\82ê\82Î\91\97\90M\82µ\82È\82¢
-                               // \96{\97\88\82Å\82 \82ê\82Î\8e\9e\8aÔ\82Å\8aÇ\97\9d\82·\82×\82«
-                               return false;
-                       }
-               }
-       }
-       if(!check){
-               return false;
-       }
-       // \82·\82×\82Ä\82Ì\83R\83l\83N\83V\83\87\83\93\82É\91\97\90M\82·\82é
-       for(ConnectionVector::iterator p = m_Connections.begin(); p != m_Connections.end(); p++){
-               if(p->m_pAvatarInformation == NULL){
-                       continue;
-               }
-               // \82·\82×\82Ä\82Ì\89¹\90º\83f\81[\83^\82ð\8fW\82ß\82é
-               unsigned char buffer[3000];
-               int length = 0;
-               for(int i = 0; i < 3000; i++){
-                       buffer[i] = 128;
-               }
-               for(ConnectionVector::iterator q = m_Connections.begin(); q != m_Connections.end(); q++){
-                       if(q->m_pAvatarInformation == NULL){
-                               continue;
-                       }
-                       // \8e©\95ª\8e©\90g\82Í\8d\87\90¬\82µ\82È\82¢\81i\8c»\8dÝ\83f\83o\83b\83O\92\86\82È\82Ì\82Å\8d\87\90¬\82µ\82Ä\82¢\82é\81j
-                       StructWaveBuffer* a_pInputWaveData = q->m_pAvatarInformation->m_Voice.getReadPointer();
-                       for(unsigned int i = 0; i < a_pInputWaveData->m_BufferSize; i++){
-                               // \97Ê\8eq\89»\83r\83b\83g\90\94\82ª8\83r\83b\83g\82Ì\8fê\8d\87\82Í\81A0\81`255 \82Ì\94Í\88Í\82Å\90U\95\9d\92l\82ð\95\\8c»\82µ\82Ü\82·\81B128 \82ª\92\86\90S(\90U\95\9d\82È\82µ)\82Å\82·\81B
-                               // 16\83r\83b\83g\82Ì\8fê\8d\87\82Í\81A-32768\81`32767 \82Ì\94Í\88Í\82Å\90U\95\9d\92l\82ð\95\\8c»\82µ\82Ü\82·\81B0 \82ª\92\86\90S(\90U\95\9d\82È\82µ)\82Å\82·\81B
-                               buffer[i] = static_cast<unsigned char>(buffer[i]) + static_cast<unsigned char>(a_pInputWaveData->m_pWaveBuffer[i]) - 128;
-                               length = a_pInputWaveData->m_BufferSize;
-                       }
-               }
-               unsigned char* p1 = buffer;
-               while(true){
-                       short in_short[FRAME_SIZE];
-                       int bitCount = 0;
-                       // Convert 8 -> 16 bits
-                       for(int i = 0; i < FRAME_SIZE; i++){
-                               // \97Ê\8eq\89»\83r\83b\83g\90\94\82ª8\83r\83b\83g\82Ì\8fê\8d\87\82Í\81A0\81`255 \82Ì\94Í\88Í\82Å\90U\95\9d\92l\82ð\95\\8c»\82µ\82Ü\82·\81B128 \82ª\92\86\90S(\90U\95\9d\82È\82µ)\82Å\82·\81B
-                               // 16\83r\83b\83g\82Ì\8fê\8d\87\82Í\81A-32768\81`32767 \82Ì\94Í\88Í\82Å\90U\95\9d\92l\82ð\95\\8c»\82µ\82Ü\82·\81B0 \82ª\92\86\90S(\90U\95\9d\82È\82µ)\82Å\82·\81B
-                               if(p1 < buffer + length){
-                                       in_short[i] = (*(p1 + i) << 8) ^ 0x8000;
-                               }
-                               else{
-                                       in_short[i] = (128 << 8) ^ 0x8000;
-                               }
-                       }
-                       p1 += FRAME_SIZE;
-
-                       // \83\8a\83Z\83b\83g
-                       speex_bits_reset(&m_SpeexData.bits);
-
-                       // \88³\8fk
-                       speex_encode_int(m_SpeexData.st, in_short, &m_SpeexData.bits);
-
-                       // \88³\8fk\83r\83b\83g\83X\83g\83\8a\81[\83\80\8eæ\93¾
-                       char cbits[200];
-                       int nbBytes = speex_bits_write(&m_SpeexData.bits, cbits, 200);
-                       bitCount += m_SpeexData.bits.nbBits;
-
-                       // \91\97\90M
-                       if(p1 >= buffer + length){
-                               p->m_pConnection->sendVoice(cbits, nbBytes, 1);
-                               break;
-                       }
-                       else{
-                               p->m_pConnection->sendVoice(cbits, nbBytes, 0);
-                       }
-                       std::cout << "\91\97\90M" << std::endl;
-               }
-       }
-       for(ConnectionVector::iterator p = m_Connections.begin(); p != m_Connections.end(); p++){
-               if(p->m_pAvatarInformation == NULL){
-                       continue;
-               }
-               p->m_pAvatarInformation->m_Voice.nextReadBuffer();
-       }
-       return true;
-}
+#include "../../common/Environment.h"\r
+#include "CServerModel.h"\r
+\r
+#include <iostream>\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// constructor\r
+////////////////////////////////////////////////////////////////////////////////\r
+CServerModel::CServerModel()\r
+{\r
+       initializeSpeex(&m_SpeexData);\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// destructor\r
+////////////////////////////////////////////////////////////////////////////////\r
+CServerModel::~CServerModel()\r
+{\r
+       for(size_t i = 0; i < m_Connections.size(); i++){\r
+               delete m_Connections[i].m_pConnection;\r
+       }\r
+       for(AvatarInformationList::iterator p = m_AvatarInformations.begin(); p != m_AvatarInformations.end(); p++){\r
+               delete *p;\r
+       }\r
+       uninitializeSpeex(&m_SpeexData);\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// initialize\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CServerModel::initialize()\r
+{\r
+       m_ServerSocket.initialize();\r
+       m_ServerSocket.openPort();\r
+       std::cout << "PortNumber = " << m_ServerSocket.getPortNumber() << std::endl;\r
+\r
+       m_Connections.resize(MAX_CONNECTION_NUMBER);\r
+       for(size_t i = 0; i < m_Connections.size(); i++){\r
+               ConnectionTuple temp;\r
+               temp.m_pConnection = new CServerConnection();\r
+               temp.m_pConnection->initialize();\r
+               m_ServerSocket.accept(temp.m_pConnection);\r
+               temp.m_pAvatarInformation = NULL;\r
+               m_Connections[i] = temp;\r
+       }\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// initialize of speex\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CServerModel::initializeSpeex(SpeexData* io_pSpeexData)\r
+{\r
+       io_pSpeexData->st = speex_encoder_init(speex_lib_get_mode(SPEEX_MODEID_NB));\r
+       io_pSpeexData->dec = speex_decoder_init(speex_lib_get_mode(SPEEX_MODEID_NB));\r
+\r
+       /* BEGIN: You probably don't need the following in a real application */\r
+#if 0\r
+       callback.callback_id = SPEEX_INBAND_CHAR;\r
+       callback.func = speex_std_char_handler;\r
+       callback.data = stderr;\r
+       speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);\r
+\r
+       callback.callback_id = SPEEX_INBAND_MODE_REQUEST;\r
+       callback.func = speex_std_mode_request_handler;\r
+       callback.data = st;\r
+       speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);\r
+#endif\r
+       /* END of unnecessary stuff */\r
+\r
+       spx_int32_t tmp;\r
+       tmp=1;\r
+       speex_decoder_ctl(io_pSpeexData->dec, SPEEX_SET_ENH, &tmp);\r
+       tmp=0;\r
+       speex_encoder_ctl(io_pSpeexData->st, SPEEX_SET_VBR, &tmp);\r
+       tmp=8;\r
+       speex_encoder_ctl(io_pSpeexData->st, SPEEX_SET_QUALITY, &tmp);\r
+       /*\r
+       tmp=1;\r
+       speex_encoder_ctl(st, SPEEX_SET_COMPLEXITY, &tmp);\r
+       */\r
+       tmp = 8000;\r
+       //speex_encoder_ctl(st, SPEEX_SET_SAMPLING_RATE, &tmp);\r
+       //speex_decoder_ctl(dec, SPEEX_SET_SAMPLING_RATE, &tmp);\r
+       //tmp = 8000;\r
+       //speex_encoder_ctl(st, SPEEX_SET_BITRATE, &tmp);\r
+\r
+       spx_int32_t frame_size;\r
+       speex_encoder_ctl(io_pSpeexData->st, SPEEX_GET_FRAME_SIZE, &frame_size);\r
+\r
+       /* Turn this off if you want to measure SNR (on by default) */\r
+       /*\r
+       tmp=1;\r
+       speex_encoder_ctl(st, SPEEX_SET_HIGHPASS, &tmp);\r
+       speex_decoder_ctl(dec, SPEEX_SET_HIGHPASS, &tmp);\r
+       */\r
+\r
+       speex_encoder_ctl(io_pSpeexData->st, SPEEX_GET_LOOKAHEAD, &io_pSpeexData->skip_group_delay);\r
+       speex_decoder_ctl(io_pSpeexData->dec, SPEEX_GET_LOOKAHEAD, &tmp);\r
+       io_pSpeexData->skip_group_delay += tmp;\r
+\r
+       speex_bits_init(&io_pSpeexData->bits);\r
+\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// uninitialize of speex\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CServerModel::uninitializeSpeex(SpeexData* io_pSpeexData)\r
+{\r
+       speex_encoder_destroy(io_pSpeexData->st);\r
+       speex_decoder_destroy(io_pSpeexData->dec);\r
+       speex_bits_destroy(&io_pSpeexData->bits);\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \8f\88\97\9d\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CServerModel::process()\r
+{\r
+       // \92Ê\90M\83N\83\89\83X\82©\82ç\83f\81[\83^\8eæ\93¾\r
+       for(ConnectionVector::iterator p = m_Connections.begin(); p != m_Connections.end(); p++){\r
+               CommunicationData* a_pData;\r
+               if(p->m_pConnection->receive(&a_pData)){\r
+                       // \83\8d\83O\83C\83\93\8f\88\97\9d\81i\83Z\83b\83V\83\87\83\93\82Æ\83\8d\83O\83C\83\93\83l\81[\83\80\82Æ\81i\83p\83X\83\8f\81[\83h\81j\82ð\93n\82·\81j\r
+                       if(a_pData->m_DataType == 'i'){\r
+                               if(login(p, a_pData->m_Data.m_LoginData.m_Name)){\r
+                                       std::cout << "login " << a_pData->m_Data.m_LoginData.m_Name << std::endl;\r
+                               }\r
+                       }\r
+                       // \83\8d\83O\83A\83E\83g\8f\88\97\9d\r
+                       else if(a_pData->m_DataType == 'o'){\r
+                               logout(p, p->m_pAvatarInformation->m_Name);\r
+                       }\r
+                       // \8dÀ\95W\8eæ\93¾\r
+                       else if(a_pData->m_DataType == 'p'){\r
+                               requestPosition(p);\r
+                       }\r
+                       // \83A\83N\83V\83\87\83\93\83R\83}\83\93\83h\82ð\8f\88\97\9d\r
+                       else if(a_pData->m_DataType == 'a'){\r
+                               requestMove(p, a_pData->m_Data.m_ActionCommand.m_CommandType);\r
+                       }\r
+                       // \89¹\90º\83f\81[\83^\82ð\8ai\94[\82·\82é\r
+                       else if(a_pData->m_DataType == 'v' && p->m_pAvatarInformation != NULL){\r
+                               std::cout << "\8eó\90M" << std::endl;\r
+                               short out_short[FRAME_SIZE];\r
+\r
+                               // \83\8a\83Z\83b\83g\r
+                               //speex_bits_reset(&m_SpeexData.bits);\r
+\r
+                               // \88³\8fk\83r\83b\83g\83X\83g\83\8a\81[\83\80\82ð\83Z\83b\83g\81i\93¯\8e\9e\82É\83\8a\83Z\83b\83g\82³\82ê\82é\81j\r
+                               speex_bits_read_from(&m_SpeexData.bits, a_pData->m_Data.m_Voice.m_Stream, a_pData->m_Data.m_Voice.m_Length);\r
+\r
+                               // \89ð\93\80\r
+                               speex_decode_int(m_SpeexData.dec, &m_SpeexData.bits, out_short);\r
+\r
+                               // Convert 16 -> 8 bits\r
+                               for(int i = 0; i < FRAME_SIZE; i++){\r
+                                       p->m_pAvatarInformation->m_Stream[p->m_pAvatarInformation->m_Length] = (out_short[i] ^ 0x8000) >> 8;\r
+                                       p->m_pAvatarInformation->m_Length++;\r
+                               }\r
+\r
+                               if(a_pData->m_Data.m_Voice.m_isEnd){\r
+                                       StructWaveBuffer* a_pOutputWaveData = p->m_pAvatarInformation->m_Voice.getWritePointer();\r
+                                       a_pOutputWaveData->m_pWaveBuffer = p->m_pAvatarInformation->m_Stream;\r
+                                       a_pOutputWaveData->m_BufferSize = p->m_pAvatarInformation->m_Length;\r
+                                       a_pOutputWaveData->m_RecorMilliSecond = 100;\r
+                                       p->m_pAvatarInformation->m_Length = 0;\r
+                                       p->m_pAvatarInformation->m_Voice.nextWriteBuffer();\r
+                                       //std::cout << "reset" << std::endl;\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+       // \89¹\90º\83f\81[\83^\82ª\82 \82ê\82Î\91\97\90M\82·\82é\r
+       sendVoice();\r
+\r
+       // \89¹\90º\82ð\8d\87\90¬\r
+       // memo: \93¯\8e\9e\82É\8eó\90M\82µ\82½\89¹\90º\82ð\81A\93¯\8e\9e\8d\8f\82Æ\82µ\82Ä\8d\87\90¬\82·\82é\r
+       // memo: \88³\8fk\89¹\90º\83f\81[\83^\82Í\95ª\8a\84\82µ\82Ä\91\97\90M\82³\82ê\82é\82½\82ß\81A\82µ\82Î\82ç\82­\82½\82ß\82Ä\82¨\82­\95K\97v\82ª\82 \82é\r
+       // memo: \82½\82ß\82½\8fê\8d\87\81A\8dÅ\8f\89\82ª\8f­\82µ\92x\82ê\82é\82¾\82¯\82Å\81A\89¹\82ª\82Æ\82¬\82ê\82é\82±\82Æ\82Í\82È\82¢\r
+       // memo: \82½\82¾\82µ\81A\8e©\95ª\8e©\90M\82Ì\90º\82Í\92x\82ê\82Ä\95·\82±\82¦\82é\82Ì\82Å\81A\8e©\95ª\8e©\90g\82Ì\89¹\82Í\91\97\82è\95Ô\82³\82È\82¢\r
+       // memo: \82Ü\82½\81A\89¹\90º\82Ì\8d\87\90¬\82Í\8ae\83L\83\83\83\89\83N\83^\81[\81i\83N\83\89\83C\83A\83\93\83g\81j\82²\82Æ\82É\90\90¬\82µ\82È\82¯\82ê\82Î\82È\82ç\82È\82¢\r
+\r
+       // \8eæ\93¾\83R\83}\83\93\83h\82É\91Î\82µ\82Ä\83f\81[\83^\91\97\90M\r
+\r
+\r
+       // to do\r
+       // \89¹\90º\82ð\8d\87\90¬\82·\82é\8fê\8d\87\81A\93¯\82\89¹\82ð\89½\93x\82à\8d\87\90¬\82µ\82È\82¢\82æ\82¤\82É\82·\82é\82½\82ß\81A\r
+       // \98^\89¹\8e\9e\8d\8f\82â\8eó\90M\8e\9e\8d\8f\82ð\97\98\97p\82µ\82Ä\81A\8f\87\94Ô\82ð\8aÔ\88á\82¦\82È\82¢\82æ\82¤\82µ\82È\82¯\82ê\82Î\82È\82ç\82È\82¢\r
+\r
+       // \89¹\8fî\95ñ\82ð\8aÈ\92P\82É\88µ\82¤\82½\82ß\81A\92Ê\90M\83N\83\89\83X\82ð\82à\82¤\8f­\82µ\82Ü\82Æ\82ß\82È\82¯\82ê\82Î\82È\82ç\82È\82¢\r
+\r
+       // Model\83N\83\89\83X\82©\82ç\82Í\92Ê\90M\82ð\8ds\82Á\82Ä\82¢\82é\82±\82Æ\82ð\88Ó\8e¯\82µ\82È\82¢\82æ\82¤\82É\82µ\82½\82¢\r
+\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// login\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CServerModel::login(ConnectionVector::iterator io_ConnectionIterator, const char* in_pLoginName)\r
+{\r
+       AvatarInformation* temp = new AvatarInformation;\r
+       strcpy(temp->m_Name, in_pLoginName);\r
+       temp->m_Position[0] = 0;\r
+       temp->m_Position[1] = 0;\r
+       temp->m_Position[2] = 0;\r
+       temp->m_Direction[0] = 1;\r
+       temp->m_Direction[1] = 0;\r
+       temp->m_Direction[2] = 0;\r
+       temp->m_Radias = 0.3;\r
+       // \82 \82Æ\82Å\8fC\90³\95K\90{\81i\83}\83W\83b\83N\83i\83\93\83o\81[\81j\r
+       temp->m_Voice.allocate(10, 100, 2080);\r
+       temp->m_Length = 0;\r
+       m_AvatarInformations.push_back(temp);\r
+\r
+       /*\r
+       // \83\8d\83O\83C\83\93\8a®\97¹\91\97\90M\r
+       CommunicationData a_SendData;\r
+       a_SendData.m_DataType = 'i';\r
+       strcpy(a_SendData.m_Data.m_LoginData.m_Name, in_pLoginName);\r
+       io_ConnectionIterator->m_pConnection->send(&a_SendData);\r
+       io_ConnectionIterator->m_pAvatarInformation = temp;\r
+       */\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// logout\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CServerModel::logout(ConnectionVector::iterator io_ConnectionIterator, const char* in_pLoginName)\r
+{\r
+       // \96¢\83\8d\83O\83C\83\93\r
+       if(io_ConnectionIterator->m_pAvatarInformation == NULL){\r
+               return false;\r
+       }\r
+\r
+       CommunicationData a_SendData;\r
+       a_SendData.m_DataType = 'o';\r
+       strcpy(a_SendData.m_Data.m_LoginData.m_Name, in_pLoginName);\r
+       io_ConnectionIterator->m_pConnection->send(&a_SendData);\r
+\r
+       std::cout << "logout " << io_ConnectionIterator->m_pAvatarInformation->m_Name << std::endl;\r
+\r
+       // \83A\83o\83^\81[\82ð\8dí\8f\9c\82·\82é\r
+       for(AvatarInformationList::iterator p = m_AvatarInformations.begin(); p != m_AvatarInformations.end(); p++){\r
+               if(*p == io_ConnectionIterator->m_pAvatarInformation){\r
+                       delete *p;\r
+               }\r
+               m_AvatarInformations.erase(p);\r
+               break;\r
+       }\r
+       io_ConnectionIterator->m_pAvatarInformation = NULL;\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \91\97\90M\8f\88\97\9d\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CServerModel::sendData()\r
+{\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// position\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CServerModel::requestPosition(ConnectionVector::iterator io_ConnectionIterator)\r
+{\r
+       // \96¢\83\8d\83O\83C\83\93\r
+       if(io_ConnectionIterator->m_pAvatarInformation == NULL){\r
+               return false;\r
+       }\r
+\r
+       if(!m_AvatarInformations.empty()){\r
+               for(AvatarInformationList::iterator p = m_AvatarInformations.begin(); p != m_AvatarInformations.end(); p++){\r
+                       CommunicationData a_SendData;\r
+                       a_SendData.m_DataType = 'p';\r
+                       strcpy(a_SendData.m_Data.m_AvatarData.m_Name, (*p)->m_Name);\r
+                       a_SendData.m_Data.m_AvatarData.m_Position[0] = (*p)->m_Position[0];\r
+                       a_SendData.m_Data.m_AvatarData.m_Position[1] = (*p)->m_Position[1];\r
+                       a_SendData.m_Data.m_AvatarData.m_Position[2] = (*p)->m_Position[2];\r
+                       a_SendData.m_Data.m_AvatarData.m_Direction[0] = (*p)->m_Direction[0];\r
+                       a_SendData.m_Data.m_AvatarData.m_Direction[1] = (*p)->m_Direction[1];\r
+                       a_SendData.m_Data.m_AvatarData.m_Direction[2] = (*p)->m_Direction[2];\r
+                       a_SendData.m_Data.m_AvatarData.m_Radias = (*p)->m_Radias;\r
+\r
+                       if(!io_ConnectionIterator->m_pConnection->send(&a_SendData)){\r
+                               std::cout << "do not send position" << std::endl;\r
+                       }\r
+               }\r
+       }\r
+       /*\r
+       else{\r
+               CommunicationData a_SendData;\r
+               a_SendBuffer.m_Length = sprintf(a_SendBuffer.m_Buffer, "p;");\r
+               if(!io_pConnection->send(&a_SendBuffer)){\r
+                       std::cout << "do not send position" << std::endl;\r
+               }\r
+       }\r
+       */\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// move\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CServerModel::requestMove(ConnectionVector::iterator io_ConnectionIterator, char in_pMoveDirection)\r
+{\r
+       const double M_PI = 3.14159265357989;\r
+       // \90l\82Ì\95à\82­\91¬\93x\82ð1\95b\8aÔ\82É1m\82Æ\82·\82é\r
+       const double a_VelocityParTimes = 1.0 / 60;\r
+       // 2\95b\82Å\90U\82è\95Ô\82é\81i180\93x = pi\81j\82Æ\82·\82é\81B\r
+       const double a_RotateParTimes = M_PI / (2 * 60);\r
+\r
+       // \96¢\83\8d\83O\83C\83\93\r
+       if(io_ConnectionIterator->m_pAvatarInformation == NULL){\r
+               return false;\r
+       }\r
+\r
+       AvatarInformation* a_pAvatarInformation = io_ConnectionIterator->m_pAvatarInformation;\r
+\r
+       if(in_pMoveDirection == 'f'){\r
+               a_pAvatarInformation->m_Position[0] += a_pAvatarInformation->m_Direction[0] * a_VelocityParTimes;\r
+               a_pAvatarInformation->m_Position[1] += a_pAvatarInformation->m_Direction[1] * a_VelocityParTimes;\r
+               a_pAvatarInformation->m_Position[2] += a_pAvatarInformation->m_Direction[2] * a_VelocityParTimes;\r
+       }\r
+       // \8cã\95û\82Ö\88Ú\93®\r
+       else if(in_pMoveDirection == 'b'){\r
+               a_pAvatarInformation->m_Position[0] -= a_pAvatarInformation->m_Direction[0] * a_VelocityParTimes;\r
+               a_pAvatarInformation->m_Position[1] -= a_pAvatarInformation->m_Direction[1] * a_VelocityParTimes;\r
+               a_pAvatarInformation->m_Position[2] -= a_pAvatarInformation->m_Direction[2] * a_VelocityParTimes;\r
+       }\r
+       // \89E\90ù\89ñ\r
+       else if(in_pMoveDirection == 'r'){\r
+               double x = a_pAvatarInformation->m_Direction[0];\r
+               double y = a_pAvatarInformation->m_Direction[1];\r
+               a_pAvatarInformation->m_Direction[0] =  x * cos(a_RotateParTimes) + y * sin(a_RotateParTimes);\r
+               a_pAvatarInformation->m_Direction[1] = -x * sin(a_RotateParTimes) + y * cos(a_RotateParTimes);\r
+       }\r
+       // \8d\90ù\89ñ\r
+       else if(in_pMoveDirection == 'l'){\r
+               double x = a_pAvatarInformation->m_Direction[0];\r
+               double y = a_pAvatarInformation->m_Direction[1];\r
+               a_pAvatarInformation->m_Direction[0] =  x * cos(a_RotateParTimes) - y * sin(a_RotateParTimes);\r
+               a_pAvatarInformation->m_Direction[1] =  x * sin(a_RotateParTimes) + y * cos(a_RotateParTimes);\r
+       }\r
+       return true;\r
+}\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// \89¹\90º\91\97\90M\r
+////////////////////////////////////////////////////////////////////////////////\r
+bool CServerModel::sendVoice()\r
+{\r
+       bool check = false;\r
+       for(ConnectionVector::iterator p = m_Connections.begin(); p != m_Connections.end(); p++){\r
+               if(p->m_pAvatarInformation != NULL){\r
+                       check = true;\r
+                       StructWaveBuffer* a_pWaveBuffer = p->m_pAvatarInformation->m_Voice.getReadPointer();\r
+                       if(a_pWaveBuffer == NULL){\r
+                               // \88ê\82Â\82Å\82à\89¹\90º\83f\81[\83^\82ª\91\8dÝ\82µ\82È\82¯\82ê\82Î\91\97\90M\82µ\82È\82¢\r
+                               // \96{\97\88\82Å\82 \82ê\82Î\8e\9e\8aÔ\82Å\8aÇ\97\9d\82·\82×\82«\r
+                               return false;\r
+                       }\r
+               }\r
+       }\r
+       if(!check){\r
+               return false;\r
+       }\r
+       // \82·\82×\82Ä\82Ì\83R\83l\83N\83V\83\87\83\93\82É\91\97\90M\82·\82é\r
+       for(ConnectionVector::iterator p = m_Connections.begin(); p != m_Connections.end(); p++){\r
+               if(p->m_pAvatarInformation == NULL){\r
+                       continue;\r
+               }\r
+               // \82·\82×\82Ä\82Ì\89¹\90º\83f\81[\83^\82ð\8fW\82ß\82é\r
+               unsigned char buffer[3000];\r
+               int length = 0;\r
+               for(int i = 0; i < 3000; i++){\r
+                       buffer[i] = 128;\r
+               }\r
+               for(ConnectionVector::iterator q = m_Connections.begin(); q != m_Connections.end(); q++){\r
+                       if(q->m_pAvatarInformation == NULL){\r
+                               continue;\r
+                       }\r
+                       // \8e©\95ª\8e©\90g\82Í\8d\87\90¬\82µ\82È\82¢\81i\8c»\8dÝ\83f\83o\83b\83O\92\86\82È\82Ì\82Å\8d\87\90¬\82µ\82Ä\82¢\82é\81j\r
+                       StructWaveBuffer* a_pInputWaveData = q->m_pAvatarInformation->m_Voice.getReadPointer();\r
+                       for(unsigned int i = 0; i < a_pInputWaveData->m_BufferSize; i++){\r
+                               // \97Ê\8eq\89»\83r\83b\83g\90\94\82ª8\83r\83b\83g\82Ì\8fê\8d\87\82Í\81A0\81`255 \82Ì\94Í\88Í\82Å\90U\95\9d\92l\82ð\95\\8c»\82µ\82Ü\82·\81B128 \82ª\92\86\90S(\90U\95\9d\82È\82µ)\82Å\82·\81B\r
+                               // 16\83r\83b\83g\82Ì\8fê\8d\87\82Í\81A-32768\81`32767 \82Ì\94Í\88Í\82Å\90U\95\9d\92l\82ð\95\\8c»\82µ\82Ü\82·\81B0 \82ª\92\86\90S(\90U\95\9d\82È\82µ)\82Å\82·\81B\r
+                               buffer[i] = static_cast<unsigned char>(buffer[i]) + static_cast<unsigned char>(a_pInputWaveData->m_pWaveBuffer[i]) - 128;\r
+                               length = a_pInputWaveData->m_BufferSize;\r
+                       }\r
+               }\r
+               unsigned char* p1 = buffer;\r
+               while(true){\r
+                       short in_short[FRAME_SIZE];\r
+                       int bitCount = 0;\r
+                       // Convert 8 -> 16 bits\r
+                       for(int i = 0; i < FRAME_SIZE; i++){\r
+                               // \97Ê\8eq\89»\83r\83b\83g\90\94\82ª8\83r\83b\83g\82Ì\8fê\8d\87\82Í\81A0\81`255 \82Ì\94Í\88Í\82Å\90U\95\9d\92l\82ð\95\\8c»\82µ\82Ü\82·\81B128 \82ª\92\86\90S(\90U\95\9d\82È\82µ)\82Å\82·\81B\r
+                               // 16\83r\83b\83g\82Ì\8fê\8d\87\82Í\81A-32768\81`32767 \82Ì\94Í\88Í\82Å\90U\95\9d\92l\82ð\95\\8c»\82µ\82Ü\82·\81B0 \82ª\92\86\90S(\90U\95\9d\82È\82µ)\82Å\82·\81B\r
+                               if(p1 < buffer + length){\r
+                                       in_short[i] = (*(p1 + i) << 8) ^ 0x8000;\r
+                               }\r
+                               else{\r
+                                       in_short[i] = (128 << 8) ^ 0x8000;\r
+                               }\r
+                       }\r
+                       p1 += FRAME_SIZE;\r
+\r
+                       // \83\8a\83Z\83b\83g\r
+                       speex_bits_reset(&m_SpeexData.bits);\r
+\r
+                       // \88³\8fk\r
+                       speex_encode_int(m_SpeexData.st, in_short, &m_SpeexData.bits);\r
+\r
+                       // \88³\8fk\83r\83b\83g\83X\83g\83\8a\81[\83\80\8eæ\93¾\r
+                       char cbits[200];\r
+                       int nbBytes = speex_bits_write(&m_SpeexData.bits, cbits, 200);\r
+                       bitCount += m_SpeexData.bits.nbBits;\r
+\r
+                       // \91\97\90M\r
+                       if(p1 >= buffer + length){\r
+                               p->m_pConnection->sendVoice(cbits, nbBytes, 1);\r
+                               break;\r
+                       }\r
+                       else{\r
+                               p->m_pConnection->sendVoice(cbits, nbBytes, 0);\r
+                       }\r
+                       std::cout << "\91\97\90M" << std::endl;\r
+               }\r
+       }\r
+       for(ConnectionVector::iterator p = m_Connections.begin(); p != m_Connections.end(); p++){\r
+               if(p->m_pAvatarInformation == NULL){\r
+                       continue;\r
+               }\r
+               p->m_pAvatarInformation->m_Voice.nextReadBuffer();\r
+       }\r
+       return true;\r
+}\r
index a137aa4..52e1654 100644 (file)
-#ifndef INC_CServerModel
-#define INC_CServerModel
-
-// \83C\83\93\83N\83\8b\81[\83h\82Í\95K\82¸\95K\97v\82È\95¨\82¾\82¯
-// \93à\95\94\82Å\97\98\97p\82·\82é\82¾\82¯\82Ì\95¨\82Í\83\\81[\83X\82É\8bL\8fq
-#include "../../common/Data.h"
-#include "../../common/CServerConnection.h"
-#include "../../common/CServerSocket.h"
-#include <list>
-#include <vector>
-
-// \92Ê\90M\83N\83\89\83X\83\8a\83X\83g
-struct ConnectionTuple{
-       CServerConnection* m_pConnection;
-       AvatarInformation* m_pAvatarInformation;
-};
-typedef std::vector<ConnectionTuple> ConnectionVector;
-
-// \83A\83o\83^\81[\8aÇ\97\9d\83\8a\83X\83g
-typedef std::list<AvatarInformation*> AvatarInformationList;
-
-
-#include <speex/speex.h>
-#pragma comment(lib, "libspeex.lib")
-#pragma comment(lib, "libspeexdsp.lib")
-/* BEGIN: You probably don't need the following in a real application */
-#include <speex/speex_callbacks.h>
-/* END of unnecessary stuff */
-
-struct SpeexData{
-       // \83G\83\93\83R\81[\83_\83n\83\93\83h\83\8b
-       void *st;
-       // \83f\83R\81[\83_\83n\83\93\83h\83\8b
-       void *dec;
-       // \95s\96¾
-       spx_int32_t skip_group_delay;
-       // \95s\96¾
-       SpeexBits bits;
-       /* BEGIN: You probably don't need the following in a real application */
-       SpeexCallback callback;
-       /* END of unnecessary stuff */
-};
-
-static const unsigned int FRAME_SIZE = 160;
-
-
-// \8aÖ\90\94\96¼\82Í\83\8d\81[\83\8f\83L\83\83\83\81\83\8b\83P\81[\83X\82Æ\82·\82é
-
-
-////////////////////////////////////////////////////////////////////////////////
-// CServerModel
-////////////////////////////////////////////////////////////////////////////////
-class CServerModel
-{
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83\81\83\93\83o\95Ï\90\94
-       ////////////////////////////////////////////////////////////////////////////////
-private:
-       // \83A\83o\83^\81[\8dÅ\91å\83\8d\81[\83h\90\94
-       static const int MAX_AVATAR_NUMBER = 10;
-       // \8dÅ\91å\90Ú\91±\90\94
-       static const int MAX_CONNECTION_NUMBER = 10;
-       // \83A\83o\83^\81[
-       AvatarInformationList m_AvatarInformations;
-       // \92Ê\90M\83N\83\89\83X
-       ConnectionVector m_Connections;
-       // \83T\81[\83o\81[\83\\83P\83b\83g
-       CServerSocket m_ServerSocket;
-
-       SpeexData m_SpeexData;
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83R\83\93\83X\83g\83\89\83N\83^
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       CServerModel();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83f\83X\83g\83\89\83N\83^
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       ~CServerModel();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \91\80\8dì\83\81\83\\83b\83h
-       ////////////////////////////////////////////////////////////////////////////////
-public:
-       // \8f\89\8aú\89»
-       bool initialize();
-       // initialize of speex
-       bool initializeSpeex(SpeexData* io_pSpeexData);
-       // uninitialize of speex
-       bool uninitializeSpeex(SpeexData* io_pSpeexData);
-       // \8f\88\97\9d
-       bool process();
-
-private:
-       // login
-       bool login(ConnectionVector::iterator io_ConnectionIterator, const char* in_pLoginName);
-       // logout
-       bool logout(ConnectionVector::iterator io_ConnectionIterator, const char* in_pLoginName);
-       // position
-       bool requestPosition(ConnectionVector::iterator io_ConnectionIterator);
-       // move
-       bool requestMove(ConnectionVector::iterator io_ConnectionIterator, char in_pMoveDirection);
-       // \89¹\90º\91\97\90M
-       bool sendVoice();
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \91®\90«\83\81\83\\83b\83h
-       ////////////////////////////////////////////////////////////////////////////////
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \83C\83e\83\8c\81[\83V\83\87\83\93
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \8fó\91Ô
-       ////////////////////////////////////////////////////////////////////////////////
-
-       ////////////////////////////////////////////////////////////////////////////////
-       // \89\89\8eZ\8eq
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \8f\83\90\88\89¼\91z\8aÖ\90\94\81A\92è\8b`\82Ì\82Ý\81i\94ñ\8eÀ\91\95\92ñ\8b\9f\81j
-       ////////////////////////////////////////////////////////////////////////////////
-       ////////////////////////////////////////////////////////////////////////////////
-       // \93à\95\94\83N\83\89\83X
-       ////////////////////////////////////////////////////////////////////////////////
-
-
-};
-
-#endif //INC_CServerModel
+#ifndef INC_CServerModel\r
+#define INC_CServerModel\r
+\r
+// \83C\83\93\83N\83\8b\81[\83h\82Í\95K\82¸\95K\97v\82È\95¨\82¾\82¯\r
+// \93à\95\94\82Å\97\98\97p\82·\82é\82¾\82¯\82Ì\95¨\82Í\83\\81[\83X\82É\8bL\8fq\r
+#include "../../common/Data.h"\r
+#include "../../common/CServerConnection.h"\r
+#include "../../common/CServerSocket.h"\r
+#include <list>\r
+#include <vector>\r
+\r
+// \92Ê\90M\83N\83\89\83X\83\8a\83X\83g\r
+struct ConnectionTuple{\r
+       CServerConnection* m_pConnection;\r
+       AvatarInformation* m_pAvatarInformation;\r
+};\r
+typedef std::vector<ConnectionTuple> ConnectionVector;\r
+\r
+// \83A\83o\83^\81[\8aÇ\97\9d\83\8a\83X\83g\r
+typedef std::list<AvatarInformation*> AvatarInformationList;\r
+\r
+\r
+#include <speex/speex.h>\r
+#pragma comment(lib, "libspeex.lib")\r
+#pragma comment(lib, "libspeexdsp.lib")\r
+/* BEGIN: You probably don't need the following in a real application */\r
+#include <speex/speex_callbacks.h>\r
+/* END of unnecessary stuff */\r
+\r
+struct SpeexData{\r
+       // \83G\83\93\83R\81[\83_\83n\83\93\83h\83\8b\r
+       void *st;\r
+       // \83f\83R\81[\83_\83n\83\93\83h\83\8b\r
+       void *dec;\r
+       // \95s\96¾\r
+       spx_int32_t skip_group_delay;\r
+       // \95s\96¾\r
+       SpeexBits bits;\r
+       // BEGIN: You probably don't need the following in a real application\r
+       SpeexCallback callback;\r
+       // END of unnecessary stuff\r
+};\r
+\r
+static const unsigned int FRAME_SIZE = 160;\r
+\r
+\r
+// \8aÖ\90\94\96¼\82Í\83\8d\81[\83\8f\83L\83\83\83\81\83\8b\83P\81[\83X\82Æ\82·\82é\r
+\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// CServerModel\r
+////////////////////////////////////////////////////////////////////////////////\r
+class CServerModel\r
+{\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83\81\83\93\83o\95Ï\90\94\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+private:\r
+       // \83A\83o\83^\81[\8dÅ\91å\83\8d\81[\83h\90\94\r
+       static const int MAX_AVATAR_NUMBER = 10;\r
+       // \8dÅ\91å\90Ú\91±\90\94\r
+       static const int MAX_CONNECTION_NUMBER = 10;\r
+       // \83A\83o\83^\81[\r
+       AvatarInformationList m_AvatarInformations;\r
+       // \92Ê\90M\83N\83\89\83X\r
+       ConnectionVector m_Connections;\r
+       // \83T\81[\83o\81[\83\\83P\83b\83g\r
+       CServerSocket m_ServerSocket;\r
+\r
+       SpeexData m_SpeexData;\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83R\83\93\83X\83g\83\89\83N\83^\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       CServerModel();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83f\83X\83g\83\89\83N\83^\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       ~CServerModel();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // static\8aÖ\90\94\81A\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \91\80\8dì\83\81\83\\83b\83h\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+public:\r
+       // \8f\89\8aú\89»\r
+       bool initialize();\r
+       // initialize of speex\r
+       bool initializeSpeex(SpeexData* io_pSpeexData);\r
+       // uninitialize of speex\r
+       bool uninitializeSpeex(SpeexData* io_pSpeexData);\r
+       // \8f\88\97\9d\r
+       bool process();\r
+\r
+private:\r
+       // \8ae\8eí\8f\88\97\9d\r
+       // login\r
+       bool login(ConnectionVector::iterator io_ConnectionIterator, const char* in_pLoginName);\r
+       // logout\r
+       bool logout(ConnectionVector::iterator io_ConnectionIterator, const char* in_pLoginName);\r
+\r
+       // \91\97\90M\8f\88\97\9d\r
+       bool sendData();\r
+\r
+       // position\r
+       bool requestPosition(ConnectionVector::iterator io_ConnectionIterator);\r
+       // move\r
+       bool requestMove(ConnectionVector::iterator io_ConnectionIterator, char in_pMoveDirection);\r
+       // \89¹\90º\91\97\90M\r
+       bool sendVoice();\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \91®\90«\83\81\83\\83b\83h\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \83C\83e\83\8c\81[\83V\83\87\83\93\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \8fó\91Ô\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \89\89\8eZ\8eq\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \8f\83\90\88\89¼\91z\8aÖ\90\94\81A\92è\8b`\82Ì\82Ý\81i\94ñ\8eÀ\91\95\92ñ\8b\9f\81j\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+       // \93à\95\94\83N\83\89\83X\r
+       ////////////////////////////////////////////////////////////////////////////////\r
+\r
+\r
+};\r
+\r
+#endif //INC_CServerModel\r
index 10b5e27..c867b14 100644 (file)
@@ -1,16 +1,16 @@
-// \8b\9e
-#include "../../common/Environment.h"
-
-// library
-#pragma comment(lib, "ws2_32.lib")
-
-
-#include "CServer.h"
-
-int main()
-{
-       CServer a_Server;
-       a_Server.initialize();
-       a_Server.mainloop();
-       return 0;
-}
+// \8b\9e\r
+#include "../../common/Environment.h"\r
+\r
+// library\r
+#pragma comment(lib, "ws2_32.lib")\r
+\r
+\r
+#include "CServer.h"\r
+\r
+int main()\r
+{\r
+       CServer a_Server;\r
+       a_Server.initialize();\r
+       a_Server.mainloop();\r
+       return 0;\r
+}\r
index aaeea34..dbe81ac 100644 (file)
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup Label="ProjectConfigurations">
-    <ProjectConfiguration Include="Debug|Win32">
-      <Configuration>Debug</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-    <ProjectConfiguration Include="Release|Win32">
-      <Configuration>Release</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-  </ItemGroup>
-  <PropertyGroup Label="Globals">
-    <ProjectGuid>{31F108CA-4A93-4744-AAA5-BF7E33B595AD}</ProjectGuid>
-    <Keyword>Win32Proj</Keyword>
-    <RootNamespace>vc2010_server</RootNamespace>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
-    <ConfigurationType>Application</ConfigurationType>
-    <UseDebugLibraries>true</UseDebugLibraries>
-    <CharacterSet>Unicode</CharacterSet>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
-    <ConfigurationType>Application</ConfigurationType>
-    <UseDebugLibraries>false</UseDebugLibraries>
-    <WholeProgramOptimization>true</WholeProgramOptimization>
-    <CharacterSet>Unicode</CharacterSet>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
-  <ImportGroup Label="ExtensionSettings">
-  </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <PropertyGroup Label="UserMacros" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <LinkIncremental>true</LinkIncremental>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <LinkIncremental>false</LinkIncremental>
-  </PropertyGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <ClCompile>
-      <PrecompiledHeader>
-      </PrecompiledHeader>
-      <WarningLevel>Level3</WarningLevel>
-      <Optimization>Disabled</Optimization>
-      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>..\..\..\speex-1.2beta3-win32\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-    </ClCompile>
-    <Link>
-      <SubSystem>Console</SubSystem>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalLibraryDirectories>..\..\..\speex-1.2beta3-win32\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
-      <PrecompiledHeader>
-      </PrecompiledHeader>
-      <Optimization>MaxSpeed</Optimization>
-      <FunctionLevelLinking>true</FunctionLevelLinking>
-      <IntrinsicFunctions>true</IntrinsicFunctions>
-      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-    </ClCompile>
-    <Link>
-      <SubSystem>Console</SubSystem>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <EnableCOMDATFolding>true</EnableCOMDATFolding>
-      <OptimizeReferences>true</OptimizeReferences>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemGroup>
-    <ClCompile Include="..\..\common\CServerConnection.cpp" />
-    <ClCompile Include="..\..\common\CServerSocket.cpp" />
-    <ClCompile Include="..\..\common\CSocket.cpp" />
-    <ClCompile Include="..\..\common\CThread.cpp" />
-    <ClCompile Include="CServer.cpp" />
-    <ClCompile Include="CServerInput.cpp" />
-    <ClCompile Include="CServerModel.cpp" />
-    <ClCompile Include="main.cpp" />
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="..\..\common\CRingBuffer.h" />
-    <ClInclude Include="..\..\common\CServerConnection.h" />
-    <ClInclude Include="..\..\common\CServerSocket.h" />
-    <ClInclude Include="..\..\common\CSocket.h" />
-    <ClInclude Include="..\..\common\CThread.h" />
-    <ClInclude Include="..\..\common\CWaveData.h" />
-    <ClInclude Include="..\..\common\Data.h" />
-    <ClInclude Include="..\..\common\Environment.h" />
-    <ClInclude Include="CServer.h" />
-    <ClInclude Include="CServerInput.h" />
-    <ClInclude Include="CServerModel.h" />
-  </ItemGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
-  <ImportGroup Label="ExtensionTargets">
-  </ImportGroup>
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <ItemGroup Label="ProjectConfigurations">\r
+    <ProjectConfiguration Include="Debug|Win32">\r
+      <Configuration>Debug</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Release|Win32">\r
+      <Configuration>Release</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+  </ItemGroup>\r
+  <PropertyGroup Label="Globals">\r
+    <ProjectGuid>{31F108CA-4A93-4744-AAA5-BF7E33B595AD}</ProjectGuid>\r
+    <Keyword>Win32Proj</Keyword>\r
+    <RootNamespace>vc2010_server</RootNamespace>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>true</UseDebugLibraries>\r
+    <CharacterSet>Unicode</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>false</UseDebugLibraries>\r
+    <WholeProgramOptimization>true</WholeProgramOptimization>\r
+    <CharacterSet>Unicode</CharacterSet>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\r
+  <ImportGroup Label="ExtensionSettings">\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <PropertyGroup Label="UserMacros" />\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <LinkIncremental>true</LinkIncremental>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <LinkIncremental>false</LinkIncremental>\r
+  </PropertyGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <ClCompile>\r
+      <PrecompiledHeader>\r
+      </PrecompiledHeader>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <Optimization>Disabled</Optimization>\r
+      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <AdditionalIncludeDirectories>..\..\..\speex-1.2beta3-win32\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
+    </ClCompile>\r
+    <Link>\r
+      <SubSystem>Console</SubSystem>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+      <AdditionalLibraryDirectories>..\..\..\speex-1.2beta3-win32\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <ClCompile>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <PrecompiledHeader>\r
+      </PrecompiledHeader>\r
+      <Optimization>MaxSpeed</Optimization>\r
+      <FunctionLevelLinking>true</FunctionLevelLinking>\r
+      <IntrinsicFunctions>true</IntrinsicFunctions>\r
+      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+    </ClCompile>\r
+    <Link>\r
+      <SubSystem>Console</SubSystem>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
+      <OptimizeReferences>true</OptimizeReferences>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemGroup>\r
+    <ClCompile Include="..\..\common\CServerConnection.cpp" />\r
+    <ClCompile Include="..\..\common\CServerSocket.cpp" />\r
+    <ClCompile Include="..\..\common\CSocket.cpp" />\r
+    <ClCompile Include="..\..\common\CThread.cpp" />\r
+    <ClCompile Include="CServer.cpp" />\r
+    <ClCompile Include="CServerInput.cpp" />\r
+    <ClCompile Include="CServerModel.cpp" />\r
+    <ClCompile Include="main.cpp" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClInclude Include="..\..\common\CRingBuffer.h" />\r
+    <ClInclude Include="..\..\common\CServerConnection.h" />\r
+    <ClInclude Include="..\..\common\CServerSocket.h" />\r
+    <ClInclude Include="..\..\common\CSocket.h" />\r
+    <ClInclude Include="..\..\common\CThread.h" />\r
+    <ClInclude Include="..\..\common\CWaveData.h" />\r
+    <ClInclude Include="..\..\common\Data.h" />\r
+    <ClInclude Include="..\..\common\Environment.h" />\r
+    <ClInclude Include="CServer.h" />\r
+    <ClInclude Include="CServerInput.h" />\r
+    <ClInclude Include="CServerModel.h" />\r
+  </ItemGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
+  <ImportGroup Label="ExtensionTargets">\r
+  </ImportGroup>\r
 </Project>
\ No newline at end of file