Menu

[r40]: / trunk / WhatsappClient / WhatsAppProtocol / Response / WhatsEventHandler.cs  Maximize  Restore  History

Download this file

114 lines (103 with data), 4.0 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
public static class WhatsEventHandler
{
#region Delegates
public delegate void MessageRecievedHandler(FMessage mess);
public delegate void StringArrayHandler(string[] value);
public delegate void BoolHandler(string from, bool value);
public delegate void PhotoChangedHandler(string from, string uJid, string photoId);
public delegate void GroupNewSubjectHandler(string from, string uJid, string subject, int t);
#endregion
#region Events
public static event MessageRecievedHandler MessageRecievedEvent;
public static event BoolHandler IsTypingEvent;
public static event GroupNewSubjectHandler GroupNewSubjectEvent;
public static event PhotoChangedHandler PhotoChangedEvent;
#endregion
#region OnMethods
internal static void OnMessageRecievedEventHandler(FMessage mess)
{
var h = MessageRecievedEvent;
if (h == null)
return;
foreach (var tmpSingleCast in h.GetInvocationList())
{
var tmpSyncInvoke = tmpSingleCast.Target as ISynchronizeInvoke;
if (tmpSyncInvoke != null && tmpSyncInvoke.InvokeRequired)
{
tmpSyncInvoke.BeginInvoke(tmpSingleCast, new object[] { mess });
continue;
}
h.BeginInvoke(mess, null, null);
}
}
internal static void OnPhotoChangedEventHandler(FMessage mess)
{
var h = MessageRecievedEvent;
if (h == null)
return;
foreach (var tmpSingleCast in h.GetInvocationList())
{
var tmpSyncInvoke = tmpSingleCast.Target as ISynchronizeInvoke;
if (tmpSyncInvoke != null && tmpSyncInvoke.InvokeRequired)
{
tmpSyncInvoke.BeginInvoke(tmpSingleCast, new object[] { mess });
continue;
}
h.BeginInvoke(mess, null, null);
}
}
internal static void OnIsTypingEventHandler(string from, bool isTyping)
{
var h = IsTypingEvent;
if (h == null)
return;
foreach (var tmpSingleCast in h.GetInvocationList())
{
var tmpSyncInvoke = tmpSingleCast.Target as ISynchronizeInvoke;
if (tmpSyncInvoke != null && tmpSyncInvoke.InvokeRequired)
{
tmpSyncInvoke.BeginInvoke(tmpSingleCast, new object[] { from, isTyping });
continue;
}
h.BeginInvoke(from, isTyping, null, null);
}
}
internal static void OnGroupNewSubjectEventHandler(string from, string uJid, string subject, int t)
{
var h = GroupNewSubjectEvent;
if (h == null)
return;
foreach (var tmpSingleCast in h.GetInvocationList())
{
var tmpSyncInvoke = tmpSingleCast.Target as ISynchronizeInvoke;
if (tmpSyncInvoke != null && tmpSyncInvoke.InvokeRequired)
{
tmpSyncInvoke.BeginInvoke(tmpSingleCast, new object[] { from, uJid, subject, t });
continue;
}
h.BeginInvoke(from, uJid, subject, t, null, null);
}
}
internal static void OnPhotoChangedEventHandler(string from, string uJid, string photoId)
{
var h = PhotoChangedEvent;
if (h == null)
return;
foreach (var tmpSingleCast in h.GetInvocationList())
{
var tmpSyncInvoke = tmpSingleCast.Target as ISynchronizeInvoke;
if (tmpSyncInvoke != null && tmpSyncInvoke.InvokeRequired)
{
tmpSyncInvoke.BeginInvoke(tmpSingleCast, new object[] { from, uJid, photoId });
continue;
}
h.BeginInvoke(from, uJid, photoId, null, null);
}
}
#endregion
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.