-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClientCore.cs
More file actions
69 lines (53 loc) · 1.56 KB
/
ClientCore.cs
File metadata and controls
69 lines (53 loc) · 1.56 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
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Threading;
//Attach to game object in scene.
public class ClientCore : GlobalCoreBase
{
/*
* Override Methods
*/
public override void init() {
addManager(connectionManager);
//EXAMPLE. Starts repeating function to send packet 1 to server.
//In practice, put code in a manager and not in this base class.
StartCoroutine(Test());
}
//EXAMPLE. Starts repeating function to send packet 1 to server.
//In practice, put code in a manager and not in this base class.
private IEnumerator Test()
{
//Wait 3 seconds before sending
yield return new WaitForSeconds(3);
//Send 100 messages 2 seconds apart.
for (int i = 0; i < 100; i++)
{
yield return new WaitForSeconds(2);
//Create packet instance
ExamplePacket_1 packet = new ExamplePacket_1();
//Assign packet data
packet.index = 243756;
packet.index2 = 1002;
//Send packet
connectionManager.sendPacketToServer(packet);
//Server will receive the packet by subscribing to event in ExampleManager. There it will output the packet data into console
}
}
public override void update()
{
updateManagers();
}
public override void shutdown()
{
shutdownManagers();
}
/*
* Internal Variables
*/
public ConnectionManager connectionManager = new ConnectionManager(false);
/*
* Internal Functions
*/
}