///
///\83R\83\81\83\93\83g\89ð\90Í\8aÖ\90\94
///
-static VOID NicoLiveParseComment(NicoLiveStream_P self,LPWSTR commentBuf,UINT_PTR endSize,LPWSTR* mailCountBuf,SIZE_T* mailCountBufSize,SIZE_T* commentCountSum,SIZE_T* commentBufSize);
+static VOID NicoLiveParseComment(NicoLiveStream_P self,LPWSTR commentBuf,UINT_PTR endSize,LPWSTR* mailCountBuf,SIZE_T* mailCountBufSize,SIZE_T* commentBufSize);
static void NicoLiveError(void *buf);
WSANETWORKEVENTS netEvents; //\83l\83b\83g\83\8f\81[\83N\83C\83x\83\93\83g
DWORD dwResult; //\83C\83x\83\93\83g\82ª\83E\83F\83C\83g\8aÖ\90\94\82Ì\8c\8b\89Ê\82ð\8ai\94[\82·\82é\95Ï\90\94
-
+
SIZE_T commentBufSize = sizeof(WCHAR) * LENGTH_2048; //\83R\83\81\83\93\83g\83o\83b\83t\83@\92·
SIZE_T mailCountBufSize = sizeof(LPWSTR) * LENGTH_256; //\83\81\81[\83\8b\82Ì\83|\83C\83\93\83^\97p\83o\83b\83t\83@\92·
-
-
-
- SIZE_T commentCountSum = 0; //\83R\83\81\83\93\83g\83J\83E\83\93\83g
WSAEVENT hRecvEvent = NULL;
//\8eó\90M\8f\80\94õ\8f\88\97\9d
+ self->chatManager.commentCountSum = 0;
hRecvEvent = WSACreateEvent();
self->chatManager.recvBuf[0] = '\0';
WSAEventSelect(self->chatManager.sock, hRecvEvent, FD_READ | FD_CLOSE);
- NicoLiveParseComment(self,commentBuf,messageBufLen + recevedLen,mailCountBuf,&mailCountBufSize,&commentCountSum,&commentBufSize);
+ NicoLiveParseComment(self,commentBuf,messageBufLen + recevedLen,mailCountBuf,&mailCountBufSize,&commentBufSize);
-static VOID NicoLiveParseComment(NicoLiveStream_P self,LPWSTR commentBuf,UINT_PTR endSize,LPWSTR* mailCountBuf,SIZE_T* mailCountBufSize,SIZE_T* commentCountSum,SIZE_T* commentBufSize){
+static VOID NicoLiveParseComment(NicoLiveStream_P self,LPWSTR commentBuf,UINT_PTR endSize,LPWSTR* mailCountBuf,SIZE_T* mailCountBufSize,SIZE_T* commentBufSize){
LPWSTR indexPtr; //\89ð\90Í\8e\9e\82Ì\8ew\95W\83|\83C\83\93\83^
NicoLiveChat nicoLiveChat; //\83`\83\83\83b\83g\83R\83\81\83\93\83g\8ai\94[\97p\8d\\91¢\91Ì
- (*commentCountSum)++;
+ self->chatManager.commentCountSum++;
isReceveChat = TRUE;
check((_heapchk() == _HEAPOK),TEXT("\83q\81[\83v\83G\83\89\81[\82Å\82·"));
_beginthread(NicoLiveSelfDisconnect,0,self);
}
- self->callBack(NICOLIVE_EVENT_RECEVE_CHAT,self,self->option,(NICOLIVE_PARAM)&nicoLiveChat,*commentCountSum);
+ self->callBack(NICOLIVE_EVENT_RECEVE_CHAT,self,self->option,(NICOLIVE_PARAM)&nicoLiveChat,self->chatManager.commentCountSum);
//chat_result\83m\81[\83h\82Ì\8fê\8d\87
}
if(recvBufTmp == recvEndPoint && isReceveChat){
- self->callBack(NICOLIVE_EVENT_RECEVE_CHATSETTLE,self,self->option,self->chatManager.chatNo,*commentCountSum);
+ self->callBack(NICOLIVE_EVENT_RECEVE_CHATSETTLE,self,self->option,self->chatManager.chatNo,self->chatManager.commentCountSum);
}
WSAEVENT endEvent;
WSAEVENT resetEvents[3];
UINT_PTR chatNo;
+ UINT_PTR commentCountSum;
DWORD commentStartTime;
time_t baseVpos;
}ChatManager,*ChatManager_P;
commentWriteButton.Create(m_hWnd,0,WC_BUTTON,WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,0);
anonymousButton.SetWindowTextW(TEXT("184"));
+ anonymousButton.SetFont(AtlGetDefaultGuiFont());
commentWriteButton.SetWindowTextW(TEXT("\8f\91\82«\8d\9e\82Ý"));
+ commentWriteButton.SetFont(AtlGetDefaultGuiFont());
return 0;
}
VOID CCommentView::OnConnect(){
m_commentListWindow.SetRedraw(FALSE);
commentlist.OnConnect();
+
SCROLLINFO vScrollInfo = {0};
- vScrollInfo.fMask = SIF_ALL;
- this->SetScrollInfo(SB_VERT,&vScrollInfo);
+ vScrollInfo.cbSize = sizeof(vScrollInfo);
+ vScrollInfo.fMask = SIF_RANGE;
+ this->SetScrollInfo(SB_VERT,&vScrollInfo,TRUE);
+
m_commentListWindow.SetRedraw(TRUE);
SCROLLINFO vScrollInfo = {0};
vScrollInfo.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
this->GetScrollInfo(SB_VERT,&vScrollInfo);
- vScrollInfo.nPage = m_commentListWindow.CalcScrolPage();
+ vScrollInfo.nPage = m_commentListWindow.CalcScrollPage();
vScrollInfo.fMask = SIF_PAGE;
this->SetScrollInfo(SB_VERT,&vScrollInfo);
BOOL scrollFlag = vScrollInfo.nPos + (int)vScrollInfo.nPage + 1>= vScrollInfo.nMax;
BOOL scrollFlag = vScrollInfo.nPos + (int)vScrollInfo.nPage >= vScrollInfo.nMax;
- vScrollInfo.fMask = SIF_RANGE;
+
+ vScrollInfo.fMask = SIF_RANGE | SIF_PAGE;
+ vScrollInfo.cbSize = sizeof(vScrollInfo);
vScrollInfo.nMax = commentCountSum;
- this->SetScrollInfo(SB_VERT,&vScrollInfo,FALSE);
-
+ vScrollInfo.nPage = m_commentListWindow.CalcScrollPage();
-
- vScrollInfo.nPage = m_commentListWindow.CalcScrolPage();
-
- vScrollInfo.fMask = SIF_PAGE;
- this->SetScrollInfo(SB_VERT,&vScrollInfo,FALSE);
+ this->SetScrollInfo(SB_VERT,&vScrollInfo);
+
+ this->GetScrollInfo(SB_VERT,&vScrollInfo);
+
if(scrollFlag == TRUE){
this->SendMessageW(WM_VSCROLL,MAKEWORD(SB_BOTTOM,0),0);
vScrollInfo.fMask = SIF_ALL;
self.GetScrollInfo(SB_VERT,&vScrollInfo);
BOOL scrollFlag = (UINT)(vScrollInfo.nPage + vScrollInfo.nPos + 1) >= (UINT)vScrollInfo.nMax;
- vScrollInfo.nPage = CalcScrolPage();
+ vScrollInfo.nPage = CalcScrollPage();
+ vScrollInfo.fMask = SIF_PAGE;
self.SetScrollInfo(SB_VERT,&vScrollInfo);
if(scrollFlag == TRUE){
}
-UINT_PTR CCommentListWindow::CalcScrolPage(){
+UINT_PTR CCommentListWindow::CalcScrollPage(){
RECT clientRect;
INT_PTR rslt = 0;
///
///\83X\83N\83\8d\81[\83\8b\83y\81[\83W\8cv\8eZ
///
- UINT_PTR CalcScrolPage();
+ UINT_PTR CalcScrollPage();
//\83v\83\89\83C\83x\81[\83g\8aÖ\90\94
private:
#pragma once
namespace nlite{
+
+//\96¼\91O\82â\83N\83\89\83X\82ð\95Ï\82¦\82½\82¢\8fê\8d\87\82Í\82±\82±\82ð\95Ï\82¦\82é
+#define CNLITESTRING_THISTYPE CNLiteString //\95¶\8e\9a\97ñ\83N\83\89\83X\96¼
+#define CNLITESTRING_INTERNALSTRINGTYPE CString //\93à\95\94\82Å\8f\88\97\9d\82ð\82·\82é\95¶\8e\9a\97ñ\83N\83\89\83X\96¼
+
+
+
+
+#define CNLITESTRING_THISTYPE_REFERENCE CNLITESTRING_THISTYPE&
+#define CNLITESTRING_INTERNALSTRINGTYPE_REFERENCE CNLITESTRING_INTERNALSTRINGTYPE&
+
+
+
///
///nlite\95¶\8e\9a\97ñ\83N\83\89\83X
///\8aù\91¶\82Ì\95¶\8e\9a\97ñ\83N\83\89\83X\82Ì\83\89\83b\83p
///
+ class CNLITESTRING_THISTYPE{
- class CNLiteString{
- //
- //\8c^\92è\8b`
- //
- private:
- typedef CString InternalString;
- typedef LPSTR StrPtr;
- typedef LPCSTR StrCPtr;
- typedef LPWSTR WStrPtr;
- typedef LPCWSTR WStrCPtr;
- typedef CHAR Char_Type;
- typedef WCHAR WChar_Type;
public:
- typedef WStrPtr NLiteStrPtr;
- typedef WStrCPtr NLiteStrCPtr;
- typedef TCHAR NLiteChar;
- typedef CNLiteString ThisType;
+
//\83\81\83\93\83o
private:
- InternalString is_string;
+ CNLITESTRING_INTERNALSTRINGTYPE is_string;
///
///\83R\83\93\83X\83g\83\89\83N\83^
///
- CNLiteString():is_string(){}
+ CNLITESTRING_THISTYPE():is_string(){}
- CNLiteString(const NLiteStrCPtr in_str):is_string(in_str){}
+ CNLITESTRING_THISTYPE(LPCTSTR in_str):is_string(in_str){}
- CNLiteString(const InternalString &in_str):is_string(in_str){}
+ CNLITESTRING_THISTYPE(const CNLITESTRING_INTERNALSTRINGTYPE_REFERENCE in_str):is_string(in_str){}
- CNLiteString(const CNLiteString &in_str):is_string(in_str.is_string){}
+ CNLITESTRING_THISTYPE(const CNLITESTRING_THISTYPE_REFERENCE in_str):is_string(in_str.is_string){}
+ ///
+ ///\95¶\8e\9a\97ñ\82Ì\92·\82³\82ð\8eæ\93¾
+ ///
UINT_PTR length(){
return _tcslen(is_string);
}
- operator NLiteStrCPtr(){
- return (NLiteStrCPtr)(LPCWSTR)is_string;
+ ///
+ ///\95¶\8e\9a\97ñ\82ð\8c\9f\8dõ
+ ///
+ template<typename T>
+ int Find(const T pszSub,int iStart = 0)const throw(){
+
+ return is_string.Find(pszSub,iStart);
+ }
+
+ ///
+ ///\8f\91\8e®\82Å\83t\83H\81[\83}\83b\83g\89»\82·\82é
+ ///
+ template<typename T>
+ void Format(T format,...){
+ va_list ap;
+ va_start(ap,format);
+
+ is_string.Format(format,ap);
+ va_end(ap);
+
+ }
+
+
+ //
+ //\89\89\8eZ\8eq
+ //
+ public:
+ operator LPCTSTR(){
+ return (LPCWSTR)is_string;
}
template<typename T>
- ThisType &operator=(const T &instr){
+ CNLITESTRING_THISTYPE_REFERENCE operator=(const T &instr){
is_string = instr;
return *this;
}
- template<typename T>
- ThisType &operator=(const T instr[]){
- is_string = instr;
+
+ CNLITESTRING_THISTYPE_REFERENCE operator=(const CNLITESTRING_THISTYPE_REFERENCE instr){
+ is_string = instr.is_string;
return *this;
}
template<typename T>
- ThisType &operator+=(const T &instr){
+ CNLITESTRING_THISTYPE_REFERENCE operator+=(const T &instr){
is_string += instr;
return *this;
}
+ CNLITESTRING_THISTYPE_REFERENCE operator+=(const CNLITESTRING_THISTYPE_REFERENCE instr){
+ is_string += instr.is_string;
+ return *this;
+ }
+
+
+ template<typename T>
+ friend CNLITESTRING_THISTYPE operator+(const CNLITESTRING_THISTYPE_REFERENCE instr1, const T &instr2){
+ return CNLITESTRING_THISTYPE(instr1.is_string + instr2);
+ }
+
+
+ template<typename T>
+ friend CNLITESTRING_THISTYPE operator+(const T &instr1, const CNLITESTRING_THISTYPE_REFERENCE instr2){
+ return CNLITESTRING_THISTYPE(instr1 + instr2.is);
+ }
+
+
+ friend CNLITESTRING_THISTYPE operator+(const CNLITESTRING_THISTYPE_REFERENCE instr1,const CNLITESTRING_THISTYPE_REFERENCE instr2){
+
+ return CNLITESTRING_THISTYPE(instr1.is_string + instr2.is_string);
+ }
+
+ template<typename T>
+ friend bool operator< (const CNLITESTRING_THISTYPE_REFERENCE instr1,const T &instr2){
+ return instr1.is_string < instr2;
+ }
+
+ template<typename T>
+ friend bool operator< (const T &instr1,const CNLITESTRING_THISTYPE_REFERENCE instr2){
+ return instr1.is_string < instr2;
+ }
+
+ friend bool operator< (const CNLITESTRING_THISTYPE_REFERENCE instr1,const CNLITESTRING_THISTYPE_REFERENCE instr2){
+ return instr1.is_string < instr2.is_string;
+ }
+
+
+ template<typename T>
+ friend bool operator> (const CNLITESTRING_THISTYPE_REFERENCE instr1,const T &instr2){
+ return instr1.is_string > instr2;
+ }
+
+ template<typename T>
+ friend bool operator> (const T &instr1,const CNLITESTRING_THISTYPE_REFERENCE instr2){
+ return instr1.is_string > instr2;
+ }
+
+ friend bool operator> (const CNLITESTRING_THISTYPE_REFERENCE instr1,const CNLITESTRING_THISTYPE_REFERENCE instr2){
+ return instr1.is_string > instr2.is_string;
+ }
+
+ template<typename T>
+ friend bool operator<= (const CNLITESTRING_THISTYPE_REFERENCE instr1,const T &instr2){
+ return instr1.is_string <= instr2;
+ }
+
+ template<typename T>
+ friend bool operator<= (const T &instr1,const CNLITESTRING_THISTYPE_REFERENCE instr2){
+ return instr1.is_string <= instr2;
+ }
+
+ friend bool operator<= (const CNLITESTRING_THISTYPE_REFERENCE instr1,const CNLITESTRING_THISTYPE_REFERENCE instr2){
+ return instr1.is_string <= instr2.is_string;
+ }
+
+
+ template<typename T>
+ friend bool operator>= (const CNLITESTRING_THISTYPE_REFERENCE instr1,const T &instr2){
+ return instr1.is_string >= instr2;
+ }
+
+ template<typename T>
+ friend bool operator>= (const T &instr1,const CNLITESTRING_THISTYPE_REFERENCE instr2){
+ return instr1.is_string >= instr2;
+ }
+
+ friend bool operator>= (const CNLITESTRING_THISTYPE_REFERENCE instr1,const CNLITESTRING_THISTYPE_REFERENCE instr2){
+ return instr1.is_string >= instr2.is_string;
+ }
+
+
+ template<typename T>
+ friend bool operator== (const CNLITESTRING_THISTYPE_REFERENCE instr1,const T &instr2){
+ return instr1.is_string == instr2;
+ }
+
+ template<typename T>
+ friend bool operator== (const T &instr1,const CNLITESTRING_THISTYPE_REFERENCE instr2){
+ return instr1.is_string == instr2;
+ }
+
+ friend bool operator== (const CNLITESTRING_THISTYPE_REFERENCE instr1,const CNLITESTRING_THISTYPE_REFERENCE instr2){
+ return instr1.is_string == instr2.is_string;
+ }
+
+
+ template<typename T>
+ friend bool operator!= (const CNLITESTRING_THISTYPE_REFERENCE instr1,const T &instr2){
+ return instr1.is_string != instr2;
+ }
+
+ template<typename T>
+ friend bool operator!= (const T &instr1,const CNLITESTRING_THISTYPE_REFERENCE instr2){
+ return instr1.is_string != instr2;
+ }
- bool operator< (const ThisType &instr) const{
- return is_string < instr.is_string;
+ friend bool operator!= (const CNLITESTRING_THISTYPE_REFERENCE instr1,const CNLITESTRING_THISTYPE_REFERENCE instr2){
+ return instr1.is_string != instr2.is_string;
}
};
NicoRecvCallBack callback;
HANDLE threadHandle;
HANDLE endEvent;
+ HANDLE receveEvent;
LPVOID option;
StreamStatus stream;
-}NicoLiveStream;
\ No newline at end of file
+}NicoLiveStream,*NicoLiveStream_P;
\ No newline at end of file
NicoLiveStream_P rslt = (NicoLiveStream_P)malloc(sizeof(NicoLiveStream));
ZeroMemory(rslt,sizeof(*rslt));
rslt->endEvent = CreateEvent(NULL,TRUE,FALSE,NULL);
+ rslt->receveEvent = CreateEvent(NULL,TRUE,FALSE,NULL);
return rslt;
}
NicoLiveStream_disConnect(*self);
CloseHandle((*self)->endEvent);
+ CloseHandle((*self)->receveEvent);
free(*self);
*self = NULL;
return;
return &self->stream;
}
+void commentthread_inteanal(void* userdata){
+
+ NicoLiveStream_P self = (NicoLiveStream_P)userdata;
+ DWORD rslt;
+ do{
+ rslt = WaitForSingleObject(self->endEvent,1000);
+
+ if(rslt != WAIT_TIMEOUT){
+ break;
+ }
+
+ SetEvent(self->receveEvent);
+
+ }while(TRUE);
+ _endthread();
+}
unsigned int WINAPI commentthread(VOID *usadata){
self->callback(NICOLIVE_EVENT_RECEVE_CHAT,self,self->option,(NICOLIVE_PARAM)&liveChat,commentcount);
}
-
+ _beginthread(commentthread_inteanal,0,self);
+ HANDLE eventarray[] = {self->endEvent,self->receveEvent};
for(int index = 0,index2; index < 65536;index++){
}
self->callback(NICOLIVE_EVENT_RECEVE_CHATSETTLE,self,self->option,100,commentcount);
- if(( rslt = WaitForSingleObject(self->endEvent,1000)) != WAIT_TIMEOUT){
+ ResetEvent(self->receveEvent);
+ rslt = WaitForMultipleObjects(ARRAY_LENGTH(eventarray),eventarray,FALSE,INFINITE);
+
+ //\83G\83\89\81[\82Ì\8fê\8d\87
+ if(rslt == WAIT_OBJECT_0 ){
goto end;
}
-
+
}
_endthreadex(0);
return 0;
-}
\ No newline at end of file
+}
+
+