-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFluorineNetClient.cs
More file actions
51 lines (46 loc) · 1.6 KB
/
FluorineNetClient.cs
File metadata and controls
51 lines (46 loc) · 1.6 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
using System;
using FluorineFx;
using FluorineFx.Net;
using FluorineFx.Messaging.Api;
using FluorineFx.Messaging.Api.Service;
using FluorineFx.AMF3;
using System.Reflection;
using System.Collections.Generic;
using System.Data;
namespace FluorineFx
{
class FluorineNetClient
{
public FluorineNetClient(string gateway) {
_gateway = gateway;
SetUp();
}
private string _gateway;
private NetConnection _netConnection;
private void SetUp(){
_netConnection = new NetConnection();
_netConnection.ObjectEncoding = ObjectEncoding.AMF3;
_netConnection.NetStatus += new NetStatusHandler(_netConnection_NetStatus);
_netConnection.Connect(_gateway);
}
public void Call<T>(string command, params object[] arguments)
{
StatusFunction errFn = new StatusFunction(ErrorOccured.ErrorReceived);
ResultFunction<T> rsltFn = new ResultFunction<T>(ProcessResult.ResultReceived<T>);
Responder<T> rpd = new Responder<T>(rsltFn, errFn);
_netConnection.Call<T>(command, rpd, arguments);
}
private void _netConnection_NetStatus(object sender, NetStatusEventArgs e)
{
string level = e.Info["level"] as string;
if (level == "error")
{
Console.WriteLine("Connection error occured: {0}", e.Info["code"] as string);
}
if (level == "status")
{
Console.WriteLine("Connection's status: {0}", (e.Info["code"] as string));
}
}
}
}