-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApplicationActor.cs
More file actions
89 lines (78 loc) · 2.55 KB
/
Copy pathApplicationActor.cs
File metadata and controls
89 lines (78 loc) · 2.55 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
using Akka.Actor;
using Serilog;
using System;
namespace CreateAR.Snap
{
/// <summary>
/// The main actor of the application.
/// </summary>
public class ApplicationActor : ReceiveActor
{
/// <summary>
/// Reference to the connection to Trellis.
/// </summary>
private IActorRef _connection;
/// <summary>
/// Reference to the image processor.
/// </summary>
private IActorRef _processor;
/// <summary>
/// Base URL of Trellis.
/// </summary>
private string _baseUrl;
/// <summary>
/// Organization id.
/// </summary>
private string _orgId;
/// <summary>
/// Token.
/// </summary>
private string _token;
/// <summary>
/// Constructor.
/// </summary>
public ApplicationActor(
string baseUrl,
string orgId,
string token,
int xOffset,
int yOffset,
int width,
int height)
{
_baseUrl = baseUrl;
_orgId = orgId;
_token = token;
_connection = Context.ActorOf(Props.Create(() => new ConnectionActor()));
_processor = Context.ActorOf(Props.Create(() => new ImageProcessingPipelineActor(
_baseUrl,
_token,
xOffset, yOffset, width, height)));
Log.Information("Starting application.");
// listen for the connection telling us to take a snapshot
Receive<TakeSnapMessage>(msg =>
{
Log.Information($"Received TakeSnapMessage : {msg}.");
_processor.Tell(new ImageProcessingPipelineActor.Start
{
Snap = new ImageProcessingPipelineActor.SnapRecord
{
OrgId = _orgId,
InstanceId = msg.InstanceId,
SessionId = msg.SessionId,
UserId = msg.UserId,
Tag = msg.Tag
}
});
});
// connect
_connection.Tell(new ConnectionActor.Connect
{
Url = $"{_baseUrl.Replace("http", "ws")}/socket.io/?nosession=true&__sails_io_sdk_version=1.2.1&__sails_io_sdk_platform=browser&__sails_io_sdk_language=javascript&EIO=3&transport=websocket",
OrgId = _orgId,
Token = _token,
Subscriber = Self
});
}
}
}