OSDN Git Service

コメント投稿から完了までのロック処理を改修
authorqwerty2501 <riot313@gmail.com>
Mon, 13 Feb 2012 14:10:47 +0000 (23:10 +0900)
committerqwerty2501 <riot313@gmail.com>
Mon, 13 Feb 2012 14:10:47 +0000 (23:10 +0900)
nlib/nlib_nicoLive.cpp
nlite.suo
nlite/nlite_commentWrite.cpp

index e3806a0..ba94803 100644 (file)
@@ -215,7 +215,6 @@ NicoLiveStream_P NicoLiveStream_new(){
        InitializeCriticalSection(&self->sessionManager.cs);
 
        self->chatManager.heartBeatTime = 60000;
-
        self->chatManager.heartBeatFlag = TRUE;
 
        
index d9427fa..18251fe 100644 (file)
Binary files a/nlite.suo and b/nlite.suo differ
index a13c4c7..2752b0c 100644 (file)
@@ -277,56 +277,39 @@ VOID CCommentWriteWindow::OnPaint(HDC hdc){
 
 VOID CSubChatEdit::EnterChatBox(LPVOID userData){
 
-       
-       ((CSubChatEdit*)userData)->SetReadOnly(TRUE);
-       if(((CSubChatEdit*)userData)->self.nicoLiveStream.IsOwner()){
-
-               Sleep(1500);
-
-       }else {
-               Sleep(3000);
-       }
-       ((CSubChatEdit*)userData)->AgreeEnter();
-
-       _endthread();
-       return;
-}
-
-BOOL CCommentWriteWindow::SendChat(){
-
-       _beginthread(CSubChatEdit::EnterChatBox,0,&this->commentSubEdit);
-       
+       auto owner = ((CSubChatEdit*)userData)->self;
+       auto &self = *((CSubChatEdit*)userData);
        CCommentMaker commentMaker;
-       std::vector<TCHAR> chat(commentSubEdit.GetWindowTextLengthW() + 1);
+       std::vector<TCHAR> chat(owner.commentSubEdit.GetWindowTextLengthW() + 1);
 
 
-       commentSubEdit.GetWindowTextW(&chat[0],chat.size());
+       owner.commentSubEdit.GetWindowTextW(&chat[0],chat.size());
        commentMaker.SetChatString(&chat[0]);
-       if(this->anonymousButton.GetCheck() == BST_CHECKED){
+       if(owner.anonymousButton.GetCheck() == BST_CHECKED){
 
                commentMaker.AddMail(ANONYMOUS_MAILCOMMAND);
        }
-       INT_PTR sizeIndex = commentSizeBox.GetCurSel();
+       INT_PTR sizeIndex = owner.commentSizeBox.GetCurSel();
        if(sizeIndex == CB_ERR)sizeIndex = 0;
-       auto &rCommentSizeInfo = *(CommentSizeInfo*)commentSizeBox.GetItemDataPtr(sizeIndex);
+       auto &rCommentSizeInfo = *(CommentSizeInfo*)owner.commentSizeBox.GetItemDataPtr(sizeIndex);
 
        if(_tcscmp(rCommentSizeInfo.userData,DEFAULT_COMMENTSIZE) != 0){
 
                commentMaker.AddMail(rCommentSizeInfo.userData);
 
        }
-       INT_PTR posIndex = commentPosBox.GetCurSel();
+       INT_PTR posIndex = owner.commentPosBox.GetCurSel();
        if(posIndex == CB_ERR)posIndex = 0;
-       auto &rCommentPosInfo = *(CommentPosInfo*)commentPosBox.GetItemDataPtr(posIndex);
+       auto &rCommentPosInfo = *(CommentPosInfo*)owner.commentPosBox.GetItemDataPtr(posIndex);
 
        if(_tcscmp(rCommentPosInfo.userData,DEFAULT_COMMENTPOS) != 0){
 
                commentMaker.AddMail(rCommentPosInfo.userData);
        }
 
-       INT_PTR colorIndex = commentColorBox.GetCurSel();
+       INT_PTR colorIndex = owner.commentColorBox.GetCurSel();
        if(colorIndex == CB_ERR)colorIndex = 0;
-       auto &rCommentColorInfo = *(CommentColorInfo*)commentColorBox.GetItemDataPtr(colorIndex);
+       auto &rCommentColorInfo = *(CommentColorInfo*)owner.commentColorBox.GetItemDataPtr(colorIndex);
 
        if(_tcscmp(rCommentColorInfo.name,DEFAULT_COMMENTCOLOR) != 0){
 
@@ -334,16 +317,15 @@ BOOL CCommentWriteWindow::SendChat(){
        }
 
 
-       BOOL rslt = FALSE;
        NLIB_RESULT code = NLIB_ERR_CODE_NOTSET;
 
-       if(nicoLiveStream.IsOwner() ==TRUE && this->ownerModeButton.GetCheck() == BST_CHECKED){
+       if(owner.nicoLiveStream.IsOwner() ==TRUE && owner.ownerModeButton.GetCheck() == BST_CHECKED){
                
-               code = nicoLiveStream.SendOwnerChat(commentMaker);
+               code = owner.nicoLiveStream.SendOwnerChat(commentMaker);
 
        } else {
 
-               code = nicoLiveStream.SendChat(commentMaker);
+               code = owner.nicoLiveStream.SendChat(commentMaker);
 
        }
 
@@ -351,14 +333,14 @@ BOOL CCommentWriteWindow::SendChat(){
 
        case NLIB_ERR_OK:
 
-               rslt = TRUE;
-               this->commentSubEdit.SetWindowText(TEXT(""));
+
+               owner.commentSubEdit.SetWindowText(TEXT(""));
                goto end;
 
        case NLIB_ERR_NOT_LIVECONNECT:
        case NLIB_FAILED_CONNECT:       
-               ::MessageBox(*this,NLIB_GetErrorMessage(code),TEXT("\83R\83\81\83\93\83g\8f\91\82«\8d\9e\82Ý\83G\83\89\81["),MB_ICONERROR | MB_OK);
-               commentSubEdit.AgreeEnter();
+               ::MessageBox(owner,NLIB_GetErrorMessage(code),TEXT("\83R\83\81\83\93\83g\8f\91\82«\8d\9e\82Ý\83G\83\89\81["),MB_ICONERROR | MB_OK);
+               owner.commentSubEdit.AgreeEnter();
                break;
 
        
@@ -367,19 +349,41 @@ BOOL CCommentWriteWindow::SendChat(){
 
        default:
                UnexpectedErrorMessageShow(TEXT("\83R\83\81\83\93\83g\8f\91\82«\8d\9e\82Ý\92\86\82É"),NLIB_GetErrorMessage(code),__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__));
-               commentSubEdit.AgreeEnter();
+               owner.commentSubEdit.AgreeEnter();
                break;
 
        }
 
 
-       rslt = FALSE;
+end:
+
+
+
+       if((owner.nicoLiveStream.IsOwner())){
 
+               Sleep(1000);
+
+       }else {
+               Sleep(3000);
+       }
+       ((CSubChatEdit*)userData)->AgreeEnter();
+
+       _endthread();
+       return;
+}
+
+BOOL CCommentWriteWindow::SendChat(){
+
+       this->commentSubEdit.SetReadOnly(TRUE);
+       _beginthread(CSubChatEdit::EnterChatBox,0,&this->commentSubEdit);
+       
        
-end:
 
+       
 
-       return rslt;
+
+
+       return TRUE;
 }