-
Notifications
You must be signed in to change notification settings - Fork 226
Expand file tree
/
Copy pathEndPointClient.cs
More file actions
44 lines (38 loc) · 1.07 KB
/
EndPointClient.cs
File metadata and controls
44 lines (38 loc) · 1.07 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SocketIOClient
{
class EndPointClient : IEndPointClient
{
public IClient Client { get; private set; }
public string EndPoint { get; private set; }
public EndPointClient(IClient client, string endPoint)
{
this.validateNameSpace(endPoint);
this.Client = client;
this.EndPoint = endPoint;
}
private void validateNameSpace(string name)
{
if (string.IsNullOrEmpty(name))
throw new ArgumentNullException("nameSpace", "Parameter cannot be null");
if (name.Contains(':'))
throw new ArgumentException("Parameter cannot contain ':' characters", "nameSpace");
}
public void On(string eventName, Action<Messages.IMessage> action)
{
this.Client.On(eventName, this.EndPoint, action);
}
public void Emit(string eventName, Object payload, Action<Object> callBack )
{
this.Client.Emit(eventName, payload, this.EndPoint, callBack);
}
public void Send(Messages.IMessage msg)
{
msg.Endpoint = this.EndPoint;
this.Client.Send(msg);
}
}
}