本文整理汇总了C#中Client.GetPublicScene方法的典型用法代码示例。如果您正苦于以下问题:C# Client.GetPublicScene方法的具体用法?C# Client.GetPublicScene怎么用?C# Client.GetPublicScene使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Client
的用法示例。
在下文中一共展示了Client.GetPublicScene方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: connect
private static async Task connect()
{
var config = ClientConfiguration.ForAccount("7794da14-4d7d-b5b5-a717-47df09ca8492", "testlatencerpc");
config.ServerEndpoint = "http://api.stormancer.com";
_client = new Client(config);
_scene = await _client.GetPublicScene("test", "");
await _scene.Connect();
}
示例2: MainImpl
private async static Task MainImpl()
{
var config = ClientConfiguration.ForAccount(ACCOUNTID, APPLICATIONNAME);
var client = new Client(config);
var scene = await client.GetPublicScene(SCENENAME, "");
var pendingRpcPing = 0;
await scene.Connect();
//wait for the sync clock to synchronize.
await Task.Delay(TimeSpan.FromSeconds(10));
var timer = Observable.Timer(TimeSpan.Zero, TimeSpan.FromMilliseconds(100));
var measures = new List<Measure>();
using (timer.Subscribe(async _ =>
{
if (pendingRpcPing < _maxPendingRpcPings)
{
Interlocked.Increment(ref pendingRpcPing);
var measure = new Measure();
measure.RequestTime = client.Clock;
measure.ServerReceptionTime = await scene.RpcTask<object, long>("rpcping", null);
measure.ReceptionTime = client.Clock;
Interlocked.Decrement(ref pendingRpcPing);
measures.Add(measure);
}
}))
{
await Task.Delay(600000);
}
//write the measures into a CSV
using (var writer = File.CreateText("output.csv"))
{
foreach (var measure in measures)
{
writer.WriteLine($"{measure.RequestTime}, {measure.ServerReceptionTime}, {measure.ReceptionTime}");
}
}
}
示例3: Start
void Start()
{
player = RTypeLobby.player;
client = RTypeLobby.client;
actualGame = RTypeLobby.actualGame;
m_connected = false;
m_connecting = true;
m_scene = null;
m_time = 0;
for (int i = 0; i < m_allies.Length; i++)
m_allies[i] = null;
if (actualGame != null)
{
Debug.Log("Connecting to " + actualGame.SceneName + "...");
client.GetPublicScene(actualGame.SceneName, player).ContinueWith(onSceneConnecting);
}
}
示例4: Connect
// Use this for initialization
public Task<Scene> Connect()
{
ClientConfiguration config;
config = ClientConfiguration.ForAccount(AccountId, Application);
config.Logger = DebugLogger.Instance;
_client = new Stormancer.Client(config);
_client.GetPublicScene(this.SceneId, "")
.ContinueWith<Scene>(task =>
{
if (task.IsFaulted)
{
Debug.LogException(task.Exception);
}
return task.Result;
}).Then(scene =>
{
lock (this._configLock)
{
this._scene = scene;
if (this._initConfig != null)
{
this._initConfig(this._scene);
}
}
return scene.Connect();
})
.ContinueWith(t =>
{
if (t.IsFaulted)
{
this._connectedTcs.SetException(t.Exception);
}
else
{
Debug.Log("Stormancer scene connected");
this._connectedTcs.SetResult(_scene);
}
});
return this.ConnectedTask;
}
示例5: Start
// Use this for initialization
void Start()
{
UniRx.MainThreadDispatcher.Initialize();
this.Text.text = "Not connected.";
var config = ClientConfiguration.ForAccount("997bc6ac-9021-2ad6-139b-da63edee8c58", "tutorial-helloworld");
var client = new Client(config);
// Gets the public scene named "hello", providing an empty string as user data.
client.GetPublicScene("msg", "")
.Then(scene =>
{
this.ConfigureScene(scene);
return scene.Connect();
})
.Then(() => UniRx.MainThreadDispatcher.Post(() => this.Text.text = "Connected to scene."));
}
示例6: Authenticate
public async Task<AuthenticationResult> Authenticate(Client client)
{
_scene = await client.GetPublicScene("authenticator", true);
var login = UserGenerator.Instance.GetLoginPassword();
await _scene.Connect();
Result = await Login(login.Item1, login.Item2);
if (!Result.Success)
{
Console.WriteLine(Result.ErrorMsg);
Result = await CreateAccount(login.Item1, login.Item2);
if(Result.Success)
{
Result = await Login(login.Item1, login.Item2);
}
}
//client.Disconnect();
return Result;
}
示例7: Connect
public void Connect()
{
if (_connecting == true)
return;
if (connexionPanel.username.text == "")
connexionPanel.errorText.text = "please enter a user name.";
else
{
_connecting = true;
Debug.Log("starting connection");
UniRx.MainThreadDispatcher.Initialize();
var Config = ClientConfiguration.ForAccount("7794da14-4d7d-b5b5-a717-47df09ca8492", "projectew2d");
var newClient = new Client(Config);
client = newClient;
localPlayer = new Player(0, connexionPanel.username.text, 0);
localPlayer.ship = playerShip;
localPlayer.color_red = connexionPanel.redSlider.value;
localPlayer.color_blue = connexionPanel.blueSlider.value;
localPlayer.color_green = connexionPanel.greenSlider.value;
playerMarker.GetComponent<Renderer>().material.color = new Color(localPlayer.color_red, localPlayer.color_green, localPlayer.color_blue);
playerShip.GetComponent<Renderer>().material.color = new Color(localPlayer.color_red, localPlayer.color_green, localPlayer.color_blue);
Debug.Log("config complete");
client.GetPublicScene("test", (myGameObject)localPlayer).ContinueWith(task =>
{
if (task.IsFaulted)
{
Debug.Log("connection failed, cannot get scene : " + task.Exception.Message);
StormancerActionHandler.Post(() =>
{
connexionPanel.errorText.text = "Connexion failed";
});
_connecting = false;
}
else
{
var newScene = task.Result;
scene = newScene;
Debug.Log("configuring routes");
scene.AddRoute("chat", onChat);
scene.AddRoute("update_position", onUpdatePosition);
scene.AddRoute("player_connected", onPlayerConnected);
scene.AddRoute("player_disconnected", onPlayerDisconnected);
scene.AddRoute("get_id", onGetId);
scene.AddRoute("update_status", onUpdateStatus);
scene.AddRoute("spawn_bullet", onBulletSpawn);
scene.AddRoute("destroy_bullet", onBulletDestroyed);
Debug.Log("connecting to remote scene");
scene.Connect().ContinueWith(t =>
{
if (scene.Connected)
{
_connected = true;
_connecting = false;
Debug.Log("connection successful");
StormancerActionHandler.Post(() => {
connexionPanel.gameObject.SetActive(false);
playerShip.GetComponent<Renderer>().enabled = true;
playerMarker.GetComponent<Renderer>().enabled = true;
gamePaused = false;
_connected = true;
});
}
else
{
Debug.Log("connection failed: " + t.Exception.InnerException.Message);
_connecting = false;
StormancerActionHandler.Post(() => {
connexionPanel.errorText.text = "Connexion failed";
});
}
});
}
});
}
}