C# Client  0.0.0.7
C# Library to interface with Corelink
CorelinkGM.cs
Go to the documentation of this file.
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4 using CoreLink;
5 
6 public class CorelinkGM : MonoBehaviour
7 {
8 
9  public string username = "Cindy", password = "Testpassword", serverName = "corelink.hpc.nyu.edu";
10  public List<GameObject> senderObjects;
11  public List<GameObject> receiverObjects;
12  [SerializeField]
13  private bool debug = true;
14 
15 
16  public static Control control;
17 
18 
19  // Start is called before the first frame update
23  void Start()
24  {
25  Credentials credentials = new Credentials(username, password);
26  Config config = new Config(serverName);
27  control = new Control(debug);
28  control.connect(config);
29  bool status = control.login(credentials);
30 
31  if (!status)
32  {
33  Debug.LogError("ERROR: Authentication failed");
34  }
35 
36  foreach (GameObject g in senderObjects)
37  {
38  g.GetComponent<SenderStream>().Initialize(ref control);
39  }
40 
41  foreach (GameObject g in receiverObjects)
42  {
43  g.GetComponent<ReceiverStream>().Initialize(ref control);
44  }
45  }
46 
47  public void startOffline(string username, string password, string serverName)
48  {
49  Credentials credentials = new Credentials(username, password);
50  Config config = new Config(serverName);
51  control = new Control(debug);
52  control.connect(config);
53  bool status = control.login(credentials);
54 
55  if (!status)
56  {
57  Debug.LogError("ERROR: Authentication failed");
58  }
59 
60  foreach (GameObject g in senderObjects)
61  {
62  g.GetComponent<SenderStream>().Initialize(ref control);
63  }
64 
65  foreach (GameObject g in receiverObjects)
66  {
67  g.GetComponent<ReceiverStream>().Initialize(ref control);
68  }
69  }
70  // Update is called once per frame
71  void Update()
72  {
73 
74  }
75  private void OnDestroy()
76  {
77  control.exit();
78  }
79 }