vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 SIMPLECOMM_DEBUG = false; -- output debug information
2  
3 SIMPLECOMM_CHARACTERSPERTICK_MAX = 512; -- char per tick
4 SIMPLECOMM_TICK_DELAY = 1; -- delay in second between tick
5  
6 local PIPE_ENTITIE = "\127p";
7  
8 SimpleComm_Channel = nil;
9 SimpleComm_Password = nil;
10 SimpleComm_ChatFrame = nil;
11  
12 SimpleComm_JoinHandler = nil;
13 SimpleComm_LeaveHandler = nil;
14  
15 local SimpleComm_Handler = nil;
16 local SimpleComm_Serialize = nil;
17 local SimpleComm_Unserialize = nil;
18 local SimpleComm_FilterText = nil;
19  
20 local SimpleComm_oldChatFrame_OnEvent = nil;
21  
22 SimpleComm_oldSendChatMessage = nil;
23 local SimpleComm_chanSlashCmd = nil;
24 local SimpleComm_chanSlashCmdUpper = nil;
25  
26 local SimpleComm_FlagListener = nil;
27  
28 local SimpleComm_messageQueueHeader = {};
29 local SimpleComm_messageQueueLast = SimpleComm_messageQueueHeader;
30 -- .delay
31 -- .to
32 -- .serialized
33 -- .next
34  
35 local SimpleComm_sentBytes = 0;
36 local SimpleComm_channelName = nil;
37  
38 SimpleComm_Disconnected = {};
39  
40 SimpleComm_DisconnectedMessage = string.format(ERR_CHAT_PLAYER_NOT_FOUND_S, "(.*)");
41 SimpleComm_AFK_MESSAGE = string.format(MARKED_AFK_MESSAGE, "(.*)");
42 SimpleComm_DND_MESSAGE = string.format(MARKED_DND, "(.*)");
43 SimpleComm_Flags = {};
44 SimpleComm_FlagTestMessage = "-= SimpleComm test message =-";
45 SimpleComm_WaitingForFlagTest = false;
46  
47 ---------------------------------------------------------------------------------
48 --
49 -- Debug
50 --
51 ---------------------------------------------------------------------------------
52 local function DEBUG_MSG(msg, high)
53 if (SIMPLECOMM_DEBUG)
54 then
55 if high then
56 ChatFrame1:AddMessage(msg, 1.0, 0.0, 0.25);
57 else
58 ChatFrame1:AddMessage(msg, 1.0, 1.0, 0.75);
59 end
60 end
61 end
62  
63 ---------------------------------------------------------------------------------
64 --
65 -- On load
66 --
67 ---------------------------------------------------------------------------------
68 function SimpleComm_OnLoad()
69 this:RegisterEvent("CHAT_MSG_WHISPER");
70 this:RegisterEvent("CHAT_MSG_CHANNEL");
71 this:RegisterEvent("CHAT_MSG_CHANNEL_NOTICE");
72 end
73  
74 ---------------------------------------------------------------------------------
75 --
76 -- Init
77 --
78 ---------------------------------------------------------------------------------
79 local function SimpleComm_joinChannel()
80 DEBUG_MSG("[SimpleComm_joinChannel] begin");
81 if ( GetChannelName(SimpleComm_Channel) == 0) then
82 local zoneChannel, channelName = JoinChannelByName(SimpleComm_Channel, SimpleComm_Password, SimpleComm_ChatFrame:GetID());
83  
84 if (zoneChannel ~= 0) then
85 local name = SimpleComm_Channel;
86 if ( channelName ) then
87 name = channelName;
88 end
89  
90 local i = 1;
91 while ( SimpleComm_ChatFrame.channelList[i] ) do
92 i = i + 1;
93 end
94 SimpleComm_ChatFrame.channelList[i] = name;
95 SimpleComm_ChatFrame.zoneChannelList[i] = zoneChannel;
96 end
97 DEBUG_MSG("[SimpleComm_joinChannel] end - false");
98 return false;
99 else
100 DEBUG_MSG("[SimpleComm_joinChannel] end - true");
101 return true;
102 end
103 end
104  
105 local function SimpleComm_leaveChannel()
106 if ( GetChannelName(SimpleComm_Channel) ~= 0) then
107 LeaveChannelByName(SimpleComm_Channel);
108 SimpleComm_Channel = nil;
109 SimpleComm_Password = nil;
110 end
111 end
112  
113 local function SimpleComm_initChannel()
114 DEBUG_MSG("[SimpleComm_initChannel] begin");
115 SimpleComm_messageQueue = { };
116 SimpleComm.update = SIMPLECOMM_TICK_DELAY;
117 DEBUG_MSG("[SimpleComm_initChannel] end");
118 return SimpleComm_joinChannel();
119 end
120  
121 local function SimpleComm_doneChannel()
122 SimpleComm.update = nil;
123 SimpleComm_leaveChannel();
124 end
125  
126 ---------------------------------------------------------------------------------
127 --
128 -- Alias
129 --
130 ---------------------------------------------------------------------------------
131 local function SimpleComm_SetAliasChannel()
132 id = GetChannelName( SimpleComm_Channel );
133 if (id~=0 and SimpleComm_aliasMustBeSet) then
134 local id = GetChannelName( SimpleComm_Channel );
135  
136 ChatTypeInfo[SimpleComm_chanSlashCmdUpper] = ChatTypeInfo["CHANNEL"..id];
137 ChatTypeInfo[SimpleComm_chanSlashCmdUpper].sticky = 1;
138  
139 setglobal("CHAT_MSG_"..SimpleComm_chanSlashCmdUpper, SimpleComm_chanAlias);
140 setglobal("CHAT_"..SimpleComm_chanSlashCmdUpper.."_GET", "["..SimpleComm_chanAlias.."] %s:\32");
141 setglobal("CHAT_"..SimpleComm_chanSlashCmdUpper.."_SEND", SimpleComm_chanAlias..":\32");
142  
143 SlashCmdList[SimpleComm_chanSlashCmdUpper] = SimpleComm_test;
144 setglobal("SLASH_"..SimpleComm_chanSlashCmdUpper.."1", "/"..SimpleComm_chanSlashCmd);
145  
146 -- hook only one time
147 if (not SimpleComm_oldSendChatMessage) then
148 SimpleComm_oldSendChatMessage = SendChatMessage;
149 SendChatMessage = SimpleComm_newSendChatMessage;
150 end
151  
152 SimpleComm_aliasMustBeSet = false;
153 end
154 end
155  
156 local function SimpleComm_UnsetAliasChannel()
157 if (SimpleComm_chanSlashCmdUpper) then
158  
159 if ( DEFAULT_CHAT_FRAME.editBox.stickyType == string.upper(SimpleComm_chanSlashCmdUpper) ) then
160 DEFAULT_CHAT_FRAME.editBox.chatType = "SAY"
161 DEFAULT_CHAT_FRAME.editBox.stickyType = "SAY"
162 end
163  
164 setglobal("CHAT_MSG_"..SimpleComm_chanSlashCmdUpper, nil);
165 setglobal("CHAT_"..SimpleComm_chanSlashCmdUpper.."_GET", nil);
166 setglobal("CHAT_"..SimpleComm_chanSlashCmdUpper.."_SEND", nil);
167  
168 SlashCmdList[SimpleComm_chanSlashCmdUpper] = nil;
169 setglobal("SLASH_"..SimpleComm_chanSlashCmdUpper.."1", nil);
170  
171 SimpleComm_aliasMustBeSet = true;
172 end
173 end
174  
175 function SimpleComm_newSendChatMessage(msg, sys, lang, name)
176 -- DEBUG_MSG("SimpleComm_newSendChatMessage("..msg..","..sys..","..NoNil(lang)..","..NoNil(name)..")");
177 if (sys == SimpleComm_chanSlashCmdUpper) then
178 return SimpleComm_oldSendChatMessage(string.gsub(msg, "|", PIPE_ENTITIE), "CHANNEL", lang, GetChannelName( SimpleComm_Channel ));
179 else
180 return SimpleComm_oldSendChatMessage(msg, sys, lang, name);
181 end
182 end;
183  
184 function SimpleComm_test()
185 DEBUG_MSG("ok");
186 end
187  
188 ---------------------------------------------------------------------------------
189 --
190 -- AFK/DND status
191 --
192 ---------------------------------------------------------------------------------
193 function SimpleComm_SetFlag(player, flag, message)
194 if player==nil then
195 player = UnitName("player");
196 if SimpleComm_FlagListener then
197 SimpleComm_FlagListener(flag, message);
198 end
199 end
200 if flag then
201 SimpleComm_Flags[player] = { flag=flag; message=message; count = 0 };
202 else
203 SimpleComm_Flags[player] = nil;
204 end
205  
206 end
207  
208 function SimpleComm_GetFlag(player)
209 if SimpleComm_Flags[player] then
210 return SimpleComm_Flags[player].flag, SimpleComm_Flags[player].message;
211 else
212 return nil;
213 end
214 end
215  
216 function SimpleComm_AddWhisper(player)
217 if SimpleComm_Flags[player] then
218 SimpleComm_Flags[player].count = SimpleComm_Flags[player].count +1;
219 end
220 end
221  
222 function SimpleComm_DelWhisper(player)
223 if SimpleComm_Flags[player] then
224 if SimpleComm_Flags[player].count>0 then
225 SimpleComm_Flags[player].count = SimpleComm_Flags[player].count -1;
226 return true;
227 end
228 end
229 return false;
230 end
231  
232 function SimpleComm_SendFlagTest()
233 SimpleComm_WaitingForFlagTest = time();
234 SendChatMessage(SimpleComm_FlagTestMessage, "WHISPER", nil, UnitName("player"));
235 end
236  
237 ---------------------------------------------------------------------------------
238 --
239 -- Envois
240 --
241 ---------------------------------------------------------------------------------
242 local function SimpleComm_SendQueue(elapsed)
243 -- DEBUG_MSG("[SimpleComm_SendQueue] begin");
244  
245 local clearAFK = GetCVar("autoClearAFK");
246 SetCVar("autoClearAFK", 0);
247 -- GetLanguageByIndex(1), GetDefaultLanguage()
248  
249 SimpleComm_sentBytes = 0;
250 SimpleComm_channelName = GetChannelName(SimpleComm_Channel);
251  
252 local previousMessage = SimpleComm_messageQueueHeader;
253 local message = SimpleComm_messageQueueHeader.next;
254  
255 while message do
256  
257 -- update delay
258 if message.delay then
259 message.delay = message.delay-elapsed;
260 if message.delay<=0 then
261 message.delay = nil;
262 end
263 end
264  
265 if message.delay then
266 -- skip the current message
267 previousMessage = message;
268 message = message.next;
269 else
270 -- check chat traffic
271 SimpleComm_sentBytes = SimpleComm_sentBytes + string.len(message.serialized);
272 if SimpleComm_sentBytes > SIMPLECOMM_CHARACTERSPERTICK_MAX then
273 SimpleComm_sentBytes = SimpleComm_sentBytes - string.len(message.serialized);
274 previousMessage = SimpleComm_messageQueueLast;
275 break;
276 end
277  
278 -- send message
279 if message.to then
280 if not SimpleComm_Disconnected[message.to] then
281 -- DEBUG_MSG("Envois a("..message.to..") de("..message.serialized..")");
282 SendChatMessage(message.serialized, "WHISPER", nil, message.to);
283 SimpleComm_AddWhisper(message.to);
284 else
285 -- Ignore the message since the player is offline.
286 SimpleComm_sentBytes = SimpleComm_sentBytes - string.len(message.serialized);
287 end
288 else
289 -- DEBUG_MSG("Envois a tous de("..message.serialized..")");
290 SendChatMessage(message.serialized, "CHANNEL", nil, SimpleComm_channelName);
291 end
292  
293 -- delete current message in queue
294 previousMessage.next = message.next;
295  
296 -- go to next message (previousMessage keeps the same value)
297 message = message.next
298 end
299  
300 end
301  
302 SimpleComm_messageQueueLast = previousMessage;
303  
304 SetCVar("autoClearAFK", clearAFK);
305 if (SimpleComm_sentBytes > 0) then
306 DEBUG_MSG("Octets envoyes:"..SimpleComm_sentBytes, true);
307 end
308  
309 -- DEBUG_MSG("[SimpleComm_SendQueue] end");
310 end
311  
312 ---------------------------------------------------------------------------------
313 --
314 -- Reception
315 --
316 ---------------------------------------------------------------------------------
317 local function SimpleComm_ParseMessage(author, text)
318 local message = SimpleComm_Unserialize(text);
319 if ((message) and (SimpleComm_Handler)) then
320 SimpleComm_Handler(author, message);
321 end
322 end
323  
324 function SimpleComm_ParseEvent(event)
325 if (SimpleComm_Channel) then
326  
327 -- event=CHAT_MSG_CHANNEL; arg1=chat message; arg2=author; arg3=language; arg4=channel name with number; arg8=channel number; arg9=channel name without number
328 if ((event == "CHAT_MSG_CHANNEL") and (arg9 == SimpleComm_Channel)) then
329 -- DEBUG_MSG("Reception depuis le channel:"..arg1);
330 SimpleComm_Disconnected[arg2] = nil;
331 SimpleComm_ParseMessage(arg2, arg1);
332  
333 elseif (event == "CHAT_MSG_WHISPER") then
334 -- DEBUG_MSG("Reception de "..arg2..":"..arg1);
335 SimpleComm_Disconnected[arg2] = nil;
336 SimpleComm_ParseMessage(arg2, arg1);
337  
338 elseif ((event == "CHAT_MSG_CHANNEL_NOTICE") and (arg9 == SimpleComm_Channel)) then
339 if (arg1 == "YOU_JOINED") then
340 if (SimpleComm_Password) then
341 SetChannelPassword(SimpleComm_Channel, SimpleComm_Password);
342 end
343 if (SimpleComm_chanSlashCmd) then
344 SimpleComm_SetAliasChannel();
345 end
346 if (SimpleComm_JoinHandler) then
347 SimpleComm_JoinHandler();
348 end
349 elseif (arg1 == "YOU_LEFT") then
350 if (SimpleComm_chanSlashCmd) then
351 SimpleComm_UnsetAliasChannel();
352 end
353 if (SimpleComm_LeaveHandler) then
354 SimpleComm_LeaveHandler();
355 end
356 end
357 end
358  
359 end
360 end
361  
362 function SimpleComm_newChatFrame_OnEvent(event)
363 if (SimpleComm_Channel) then
364  
365 if ((event == "CHAT_MSG_CHANNEL") and (arg9 == SimpleComm_Channel)) then
366  
367 -- Hide if this is an internal message
368 if SimpleComm_FilterText(arg1) then
369 return;
370 end
371  
372 -- the message is shown in this ChatFrame ?
373 local info;
374 local found = 0;
375 local channelLength = strlen(arg4);
376 for index, value in this.channelList do
377 if ( channelLength > strlen(value) ) then
378 -- arg9 is the channel name without the number in front...
379 if ( ((arg7 > 0) and (this.zoneChannelList[index] == arg7)) or (strupper(value) == strupper(arg9)) ) then
380 found = 1;
381 info = ChatTypeInfo["CHANNEL"..arg8];
382 break;
383 end
384 end
385 end
386 if ( (found == 0) or not info ) then
387 return;
388 end
389  
390 -- unpack PIPE_ENTITIE
391 arg1 = string.gsub(arg1, PIPE_ENTITIE, "|")
392  
393 if (SimpleComm_chanSlashCmdUpper) then
394 event = "CHAT_MSG_"..SimpleComm_chanSlashCmdUpper;
395 arg4 = ""; -- channel name with number
396 end
397 end
398  
399 if (event == "CHAT_MSG_SYSTEM") then
400 local iStart, iEnd, playerName = string.find(arg1, SimpleComm_DisconnectedMessage);
401 if iStart then
402 if SimpleComm_Disconnected[playerName] then
403 if time()-SimpleComm_Disconnected[playerName] < 2 then
404 return;
405 end
406 else
407 SimpleComm_Disconnected[playerName] = time();
408 end
409 end
410  
411 local iStart, iEnd, message = string.find(arg1, SimpleComm_AFK_MESSAGE);
412 if iStart or arg1==MARKED_AFK then
413 SimpleComm_SetFlag(nil, "AFK", message);
414 end
415  
416 local iStart, iEnd, message = string.find(arg1, SimpleComm_DND_MESSAGE);
417 if iStart then
418 SimpleComm_SetFlag(nil, "DND", message);
419 end
420  
421 if arg1==CLEARED_AFK or arg1==CLEARED_DND then
422 SimpleComm_SetFlag(nil, nil, nil);
423 end
424 end
425  
426 if (event == "CHAT_MSG_WHISPER") then
427 if SimpleComm_FilterText(arg1) or arg1==SimpleComm_FlagTestMessage then
428 return;
429 end
430 end
431  
432 if (event == "CHAT_MSG_WHISPER_INFORM") then
433 if SimpleComm_FilterText(arg1) or arg1==SimpleComm_FlagTestMessage then
434 return;
435 end
436 end
437  
438 if (event == "CHAT_MSG_CHANNEL_JOIN") and (arg9 == SimpleComm_Channel) then
439 SimpleComm_Disconnected[arg2] = nil;
440 return;
441 end
442  
443 if (event == "CHAT_MSG_CHANNEL_LEAVE") and (arg9 == SimpleComm_Channel) then
444 -- to avoid bug #1315237 : guess that player is offline if he isn't on the channel
445 SimpleComm_Disconnected[arg2] = time();
446 return;
447 end
448  
449 if event == "CHAT_MSG_AFK" or event == "CHAT_MSG_DND" then
450 if SimpleComm_DelWhisper(arg2) then
451 return;
452 elseif SimpleComm_WaitingForFlagTest and arg2==UnitName("player") then
453 -- whisper to myself, and SimpleComm is waiting for the AFK/DND status
454 if (SimpleComm_WaitingForFlagTest-time())<10 then
455 -- event before 10 seconds -> the player is AFK/DND
456 if event=="CHAT_MSG_AFK" then
457 SimpleComm_SetFlag(nil, "AFK", arg1);
458 elseif event=="CHAT_MSG_DND" then
459 SimpleComm_SetFlag(nil, "DND", arg1);
460 end
461 SimpleComm_WaitingForFlagTest = false;
462 return
463 else
464 -- event 10 seconds after the init -> the player wrote and sent a whisper to himself while he is AFK/DND.
465 SimpleComm_WaitingForFlagTest = false;
466 end
467 end
468 end
469 else
470 if event=="CHAT_MSG_CHANNEL" or event=="CHAT_MSG_WHISPER" or event=="CHAT_MSG_WHISPER_INFORM" then
471 if SimpleComm_FilterText and SimpleComm_FilterText(arg1) then
472 return;
473 end
474 end
475 end
476  
477 SimpleComm_oldChatFrame_OnEvent(event);
478 end
479 SimpleComm_oldChatFrame_OnEvent = ChatFrame_OnEvent;
480 ChatFrame_OnEvent = SimpleComm_newChatFrame_OnEvent;
481  
482 ---------------------------------------------------------------------------------
483 --
484 -- Timer
485 --
486 ---------------------------------------------------------------------------------
487 function SimpleComm_OnUpdate(elapsed)
488 if (this.update) then
489 this.update = this.update - elapsed;
490 if (this.update <=0) then
491 SimpleComm_SendQueue(SIMPLECOMM_TICK_DELAY - this.update);
492 this.update = SIMPLECOMM_TICK_DELAY;
493 end
494 elseif (this.initChannel) then
495 this.initChannel = this.initChannel - elapsed;
496 if (this.initChannel <= 0) then
497 SimpleComm_initChannel();
498 this.initChannel = nil;
499 end
500 end
501 end
502  
503 ---------------------------------------------------------------------------------
504 --
505 -- Hook into Ephemeral
506 --
507 ---------------------------------------------------------------------------------
508 local function initEphemeralHook()
509 if ep and ep.VERSION_NUMERIC then
510 ep.UnregisterForEvent( "CHAT_MSG_WHISPER", ep.RespondToWhisper )
511 ep.UnregisterForEvent( "CHAT_MSG_WHISPER_INFORM", ep.RespondToWhisperNotice )
512 ep.RegisterForEvent( "CHAT_MSG_WHISPER", SimpleComm_EphemeralRespondToWhisper )
513 ep.RegisterForEvent( "CHAT_MSG_WHISPER_INFORM", SimpleComm_EphemeralRespondToWhisperNotice )
514 end
515 end
516  
517 if ep and not ep.UnregisterForEvent then
518 function ep.UnregisterForEvent(event, callback)
519 if ep.RegisteredEvents[ event ] then
520 for index, currentCB in ep.RegisteredEvents[ event ] do
521 if currentCB == callback then
522 table.remove( ep.RegisteredEvents[ event ], index);
523 end
524 end
525 end
526 end
527 end
528  
529 function SimpleComm_EphemeralRespondToWhisper( event, parameters )
530 if not SimpleComm_FilterText(parameters[1]) then
531 ep.RespondToWhisper(event, parameters);
532 end
533 end
534  
535 function SimpleComm_EphemeralRespondToWhisperNotice( event, parameters )
536 if not SimpleComm_FilterText(parameters[1]) then
537 ep.RespondToWhisperNotice(event, parameters);
538 end
539 end
540  
541  
542 ---------------------------------------------------------------------------------
543 --
544 -- Fonctions publiques
545 --
546 ---------------------------------------------------------------------------------
547 function SimpleComm_SendMessage(who, msg, delay)
548 if not(who and SimpleComm_Disconnected[who]) then
549 SimpleComm_messageQueueLast.next = {to=who; serialized=SimpleComm_Serialize(msg); delay=delay };
550 SimpleComm_messageQueueLast = SimpleComm_messageQueueLast.next;
551 end
552 end
553  
554 function SimpleComm_SendRawMessage(who, message, delay)
555 if not(who and SimpleComm_Disconnected[who]) then
556 SimpleComm_messageQueueLast.next = {to=who; serialized=message; delay=delay };
557 SimpleComm_messageQueueLast = SimpleComm_messageQueueLast.next;
558 end
559 end
560  
561 function SimpleComm_PreInit(FilterText)
562 SimpleComm_FilterText = FilterText;
563 end
564  
565 function SimpleComm_Init(Channel, Password, ChatFrame, OnJoin, OnLeave, OnMessage, Serialize, Unserialize, FilterText)
566 DEBUG_MSG("[SimpleComm_Init] begin");
567 -- Pour la reception
568 SimpleComm_Handler = OnMessage;
569 SimpleComm_JoinHandler = OnJoin;
570 SimpleComm_LeaveHandler = OnLeave;
571 SimpleComm_Serialize = Serialize;
572 SimpleComm_Unserialize = Unserialize;
573 SimpleComm_FilterText = FilterText;
574 SimpleComm_ChatFrame = ChatFrame;
575  
576 -- Init Channel
577 SimpleComm_Channel = Channel;
578 SimpleComm_Password = Password;
579 local onChannelNow = SimpleComm_initChannel();
580  
581 -- Init hook into Ephemeral
582 initEphemeralHook();
583  
584 -- AFK/DND test for myself
585 SimpleComm_SendFlagTest();
586  
587 --
588 if (onChannelNow) then
589 SimpleComm_JoinHandler();
590 end
591  
592 -- Set timer
593 SimpleComm:Show();
594  
595 DEBUG_MSG("[SimpleComm_Init] end");
596 end
597  
598 function SimpleComm_InitAlias(chanSlashCmd, chanAlias)
599 DEBUG_MSG("[SimpleComm_InitAlias] begin");
600 -- unset previous alias
601 if (SimpleComm_chanSlashCmd) then
602 SimpleComm_UnsetAliasChannel();
603 end
604  
605 -- set alias
606 SimpleComm_chanSlashCmd = chanSlashCmd;
607 SimpleComm_chanSlashCmdUpper = string.upper(chanSlashCmd);
608 SimpleComm_chanAlias = chanAlias;
609  
610 SimpleComm_aliasMustBeSet = true;
611 SimpleComm_SetAliasChannel();
612 DEBUG_MSG("[SimpleComm_InitAlias] end");
613 end
614  
615 function SimpleComm_SetChannel(Channel, Password)
616 if (Channel ~= SimpleComm_Channel) then
617 -- done
618 if (SimpleComm_chanSlashCmd) then
619 SimpleComm_UnsetAliasChannel();
620 end
621 SimpleComm_doneChannel();
622 -- set channel
623 SimpleComm_Channel = Channel;
624 SimpleComm_Password = Password;
625 -- init alias / joinHandler
626 local onChannelNow = (GetChannelName(SimpleComm_Channel) ~= 0);
627 if (onChannelNow) then
628 SimpleComm_JoinHandler();
629 if (SimpleComm_chanSlashCmd) then
630 SimpleComm_SetAliasChannel();
631 end
632 end
633 -- call SimpleComm_initChannel in 2 seconds
634 SimpleComm.initChannel = 2;
635 end
636 end
637  
638 function SimpleComm_SetFlagListener(flagListener)
639 SimpleComm_FlagListener = flagListener;
640 end