1 #define _CRT_SECURE_NO_WARNINGS 1 //vc++
\82Ì
\82¨
\82¹
\82Á
\82©
\82¢
\82È
\8cx
\8d\90\82ð
\8fÁ
\82·
\83}
\83N
\83\8d
2 #define _CRT_NON_CONFORMING_SWPRINTFS 1 //vc++
\82Ì
\82¨
\82¹
\82Á
\82©
\82¢
\82È
\8cx
\8d\90\82ð
\8fÁ
\82·
\83}
\83N
\83\8d
5 #include <nlib\nlib_define.h>
11 #include <qwerty\windebuger.h>
15 static void *nlibmemory;
16 static BROWSERTYPE browserType;
17 static unsigned int WINAPI commentthread(VOID *usadata);
18 NicoLiveStream_P NicoLiveStream_new(){
20 NicoLiveStream_P rslt = (NicoLiveStream_P)malloc(sizeof(NicoLiveStream));
21 ZeroMemory(rslt,sizeof(*rslt));
22 rslt->endEvent = CreateEvent(NULL,TRUE,FALSE,NULL);
26 VOID NicoLiveStream_delete(NicoLiveStream_P* self){
28 NicoLiveStream_disConnect(*self);
29 CloseHandle((*self)->endEvent);
35 NicoVideoAuth_P NicoVideoAuth_new(){
37 return (NicoVideoAuth_P)malloc(65536);
40 VOID NicoVideoAuth_delete(NicoVideoAuth_P *self){
47 NLIB_RESULT InitializeNLIB(HINTERNET hInternet){
49 nlibmemory = malloc(65536);
60 NLIB_RESULT NicoVideoAuth_getNicoVideoAuth(NicoVideoAuth_P self,BROWSERTYPE browserType){
62 ::browserType = browserType;
67 NLIB_RESULT NicoLiveStream_connect(NicoLiveStream_P self,NicoVideoAuth_P nicoVideoAuth,LPCWSTR url,NicoRecvCallBack callback,LPVOID option){
69 NLIB_RESULT rslt = NLIB_ERR_OK;
71 NicoLiveStream_disConnect(self);
73 self->callback = callback;
74 self->option = option;
75 self->threadHandle = (HANDLE)_beginthreadex(NULL,0,commentthread,self,0,NULL);
82 VOID NicoLiveStream_disConnect(NicoLiveStream_P self){
84 SetEvent(self->endEvent);
85 if(self->threadHandle != INVALID_HANDLE_VALUE){
86 WaitForSingleObject(self->threadHandle,INFINITE);
87 CloseHandle(self->threadHandle);
92 self->threadHandle = NULL;
94 ResetEvent(self->endEvent);
98 StreamStatus_P NicoLiveStream_getStreamStatus(NicoLiveStream_P self){
100 self->stream.base_time = 1324709820;
101 self->stream.open_time = 1324709820;
102 self->stream.end_time = 1324713599;
103 self->stream.start_time = 1324710000;
105 _tcscpy(self->stream.id,TEXT("lv75313550"));
106 _tcscpy(self->stream.default_community,TEXT("co1187609"));
108 self->stream.is_owner = FALSE;
109 self->stream.provider_type = COMMUNITY_PROVIDER_TYPE;
112 return &self->stream;
116 unsigned int WINAPI commentthread(VOID *usadata){
118 NicoLiveStream_P self = (NicoLiveStream_P)usadata;
120 NicoLiveThreadComment threadcomment;
121 threadcomment.last_res = TEXT("256");
122 threadcomment.server_time = TEXT("12345467");
123 threadcomment.thread = TEXT("1234567");
124 threadcomment.ticket = TEXT("0x12334445");
125 self->callback(NICOLIVE_EVENT_RECEVE_CONNECTRESULT,self,self->option,(NICOLIVE_PARAM)&threadcomment,0);
127 NicoLiveChat liveChat;
128 TCHAR noBuf[sizeof(UINT_PTR) * 8];
129 liveChat.anonymity = TEXT("");
130 TCHAR user_idBuffer[256];
131 liveChat.date = TEXT("1324713598");
132 liveChat.locale = TEXT("jp");
133 LPCTSTR mails[] = {TEXT("184"),NULL};
134 liveChat.mail = &mails[0];
135 liveChat.mailCount = ARRAY_LENGTH(mails) - 1;
136 liveChat.name = TEXT("");
138 liveChat.premium = TEXT("1");
139 liveChat.thread = TEXT("1000254");
140 LPCTSTR user_id_format = TEXT("testuser%d");
141 liveChat.user_id = user_idBuffer;
142 liveChat.vpos = TEXT("8852");
143 int commentcount = 1;
146 srand((unsigned int)time(NULL));
148 for(int indexfirst = 0; indexfirst < 10000;indexfirst++){
149 liveChat.chatBuf = commentcount % 2 == 0 ? TEXT("testcomment
\82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 ") : TEXT("test");
150 _stprintf((LPTSTR)liveChat.user_id,user_id_format,rand() % 15);
151 _stprintf((LPTSTR)liveChat.no,TEXT("%u"),commentcount);
152 self->callback(NICOLIVE_EVENT_RECEVE_CHAT,self,self->option,(NICOLIVE_PARAM)&liveChat,indexfirst);
157 for(int index = 0,index2; index < 100;index++){
160 for(index2 = 0;index2 < 3;index2++){
162 liveChat.chatBuf = commentcount % 2 == 0 ? TEXT("testcomment
\82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 \82 ") : TEXT("test");
163 _stprintf((LPTSTR)liveChat.user_id,user_id_format,rand() % 15);
164 _stprintf((LPTSTR)liveChat.no,TEXT("%u"),commentcount);
165 self->callback(NICOLIVE_EVENT_RECEVE_CHAT,self,self->option,(NICOLIVE_PARAM)&liveChat,index + index2);
169 self->callback(NICOLIVE_EVENT_RECEVE_CHATSETTLE,self,self->option,100,commentcount);
170 if(( rslt = WaitForSingleObject(self->endEvent,0)) != WAIT_TIMEOUT){