Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion include/pitaya.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ typedef struct {
PC_EXPORT int pc_lib_version(void);
PC_EXPORT const char* pc_lib_version_str(void);

// This version of the function returns an owned version string,
// that the application has to call free on. This is useful for interop with
// C#, since it will always free a returned string from a unmanaged function.
PC_EXPORT const char* pc_lib_version_owned_str(void);

/**
* If you do use default log callback,
* this function will change the level of log out.
Expand Down Expand Up @@ -363,7 +368,6 @@ PC_EXPORT int tr_uv_tls_set_ca_file(const char* ca_file, const char* ca_path);
* Macro implementation
*/
#define pc_lib_version() PC_VERSION_NUM
#define pc_lib_version_str() PC_VERSION_STR

#ifdef __cplusplus
}
Expand Down
10 changes: 10 additions & 0 deletions src/pc_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -460,3 +460,13 @@ void pc_lib_skip_key_pin_check(bool should_skip)
{
pc__skip_key_pin_check = should_skip;
}

const char *pc_lib_version_str(void)
{
return PC_VERSION_STR;
}

const char* pc_lib_version_owned_str(void)
{
return pc_lib_strdup(pc_lib_version_str());
}
31 changes: 26 additions & 5 deletions unity/PitayaExample/Assets/Example.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,40 @@
using System.IO;
using UnityEngine;
using Pitaya;
using Pitaya.SimpleJson;
using UnityEngine.UI;

public class Example : MonoBehaviour
{
private PitayaClient _client;
private bool _connected;
private bool _requestSent;

public Button GetDataButton;

// Use this for initialization
private void Start()
{
GetDataButton.onClick.AddListener(() =>
{
_client.Request("connector.getsessiondata",
action: data =>
{
Debug.LogFormat("GetSessionData: {0}", data);
},
errorAction: err =>
{
Debug.LogFormat("GetSessionData Error: {0}", err);
});
});

// _client = new PitayaClient("ca.crt");
_client = new PitayaClient();
_client = new PitayaClient(new PitayaMetrics.Config(stats =>
{
Debug.Log("=========> Received connection stats!");
Debug.Log(stats.Serialize());
}, "connector.getsessiondata"));

_connected = false;
_requestSent = false;

Expand All @@ -30,7 +52,7 @@ private void Start()
}
};

_client.Connect("a1d127034f31611e8858512b1bea90da-838011280.us-east-1.elb.amazonaws.com", 3251,
_client.Connect("libpitaya-tests.tfgco.com", 3251,
new Dictionary<string, string>
{
{"oi", "mano"}
Expand All @@ -43,12 +65,11 @@ private void Update()
if (_connected && !_requestSent)
{
_client.Request("connector.getsessiondata",
(data) =>
action: data =>
{
Debug.Log("Got request data: " + data);
File.WriteAllText("/Users/lhahn/Downloads/OH_MY_GOD.txt", "I Got the request data: " + data);
},
(err) =>
errorAction: (err) =>
{
Debug.LogError("Got error: code = " + err.Code + ", msg = " + err.Msg);
});
Expand Down
Loading