Quantcast
Channel: JavaScript and TypeScript — Photon Engine
Viewing all 162 articles
Browse latest View live

Running LoadBalancing Demo with custom server

$
0
0
How can I run the demo with custom server? The first argument for LoadBalancingClient is only accepting protocol and setting MasterAddress in cloud-app-info.js does nothing.

Edit: I'm able to run it by replacing this line in app.ts and rebuild the project:
this.connectToRegionMaster("EU");
with
this.setMasterServerAddress("ws://<your server address:port");
this.setNameServerAddress("ws://<your server address:port");
this.connect();

Photon Construct 2 failing on Ipad

$
0
0
Love the idea of adding photon too Construct 2, would happily pay for it, but...

Currently I get the following error when running the test in an iPad, in either safari or chrome:

NameServer peer connect failed. [url=ws://ns.exitgames.com:9093/3002]ws://ns.exitgames.com:9093/3002[/url]

Works fine on other platforms.

No iPad support is a downer, I hoped photon would save me going to websocket directly, hope I am doing something wrong.

update: Tried both the provided demos (after adding AppID number) on iPad (iPad Air 2 64GB), and got the same error.


https://www.scirra.com/forum/viewtopic. ... 47#p915547

Migration from Flash to Javascript

$
0
0
Hey! I have online flash game, that uses Flash on client side. I want switch to JavaScript, but have questions about JS Photon libarary:

Seems like Flash socket and WebSocket is not the same thing? Am I right?
Do I need to ask our server side programmer to make changes on server, to support websockets?

In Flash I had:
const SERVER_URL:String = "127.0.0.1";
const PORT:int = 9090;
const POLICY_PORT:int = 843;

var peer:PhotonPeer = new PhotonPeer();
peer.initializeConnection(SERVER_URL, PORT, POLICY_PORT);

so I tried to repeat same code in js:
var peer = new Photon.PhotonPeer('ws://127.0.0.1:9090");
WebSocket connection to 'ws://127.0.0.1:9090' failed: Error during WebSocket handshake: net::ERR_CONNECTION_RESET
Photon-Javascript_SDK.js:721 'WebSocket.URL' is deprecated. Please use 'WebSocket.url' instead.

Photon JS and Photon Unity

$
0
0
I've already developed a game using Photon and I'm planning to develop a HTML5 version for it. Is it possible for PhotonJS and Photon Unity to communicate with each other using RPC?

web-based Javascript -> unity3D

$
0
0
Hello everyone,

how can I communicate between webbased javascript and unity3d via photon (i already have the javascript sdk)? It's quite easy to start communication between Unity and Unity, but the documentation and the examples did'nt really help me.

I want to control events and movement through webbased interface via tablet / smartphone as an external controller. Can you give me a small thin example how i can transport a variable or an event from javascript to unity3d via photon? This could help me as a template which I could develope further.

Thank you very much in advance!

Documentation dead links

$
0
0
Hi there,

in your documentation:
http://doc-api.photonengine.com/en/realtime/current/javascript/doc/

the link
https://doc.photonengine.com/photon-server/liteconcepts/#cat-Application - Lite & Lite Lobby

ends nowhere.

Additionally I find the documentation very poor at least if you're NOT want to go with Unity.

I'm currently in the process of writing a wrapper for all platforms for a cross compiler and that's a bad thing to have almost no usable documentation, an outdated Android Java SDK and so on...

Photon peer disconnect & reconnect

$
0
0
Hi! How to do reconnect right way, for example

var peer = new Photon.PhotonPeer(URL_SERVER);
var connectButton = function () { peer.connect() };
var disconnectButton = function () { peer.disconnect() };
When I'm trying to connect again after disconnect order - nothing happens. I have manually recreate photon peer and connect with new peer.

Custon server

$
0
0
  1. I can use other servers?
  2. I no, please tell me a Photon WS server's adress.
  3. It's "ws1.photonengine.com"?

unclear documentation of data parameter to PhotonPeer.SendOperation()

$
0
0
Please add an example of the format for the data parameter to the documentation of PhotonPeer.SendOperation().

Current documentation:
data 	object 	<optional>	Parameters of operation as key-value pairs.
Suggested documentation:
data 	array 	<optional>	Parameters of operation as a flattened array of key-value pairs: [key1, value1, key2, value2...]

I had to go dig through the source of photon-chat.js to figure out how to call SendOperation properly. I interpreted "key-value pairs" as { key1: value1... } or [[key1, value1],[key2, value2]...]. I would not interpret the original description as a flattened array.

bug: keep-alive timer only starts if an operation request is sent

$
0
0
SDK version: 4.0.0.2
description:
If a client app does not explicitly send an operation request after connecting to the server, the keep-alive timer does not start. Consequently, the client will be disconnected from the server after the timeout expires.

fix:
# from photon.js:444
PhotonPeer.prototype._onConnect = function () {
this._logger.debug('PhotonPeer[_onConnect] - Connected successfully! Raising "connect" event ...');
this._isConnecting = false;
this._isConnected = true;
this._dispatchPeerStatus(PhotonPeer.StatusCodes.connect);
this.resetKeepAlive(); # add this line
};

Webhook for GameSparks empty Request_Body

$
0
0
Hi Photon,

I'm using webhook topost info to GameSparks server when player leave a room. I have successfully read the path = GameLeave and REQUEST_BODY from Post info but the REQUES_BODY always return empty so I can't use it to determine anything, is there any reason this could be empty?

WebRPC QueueFull Error

$
0
0
Hello,

I got this strange "Queue is full. MaxQueuedRequests:5000" error from my server. The full error message is:

"HttpQueueResult:QueueFull, WebStatus:Success, Exception :System.Exception: Queue is full. MaxQueuedRequests:5000"

My web server is pretty stable and running fine. I cannot find similar problem on the Internet. So if you have any similar issue, plz help me. This is happening in a live server. Thanks!

No state change or after trying to create room that is already created

$
0
0
If trying to create a room that was already there, I was expecting to join it, or get some sort of error. Overriding onError and onReadyStateChange gives me nothing, it just fails silently as far as I can tell. Is there anything I can do to detect when this has happened?

How do you make secure websockets work?

$
0
0
Whenever I chose to start the client with Photon.ConnectionProtocol.Wss, I get the following error:

WebSocket connection to 'wss://app-eu.exitgamescloud.com:19090/' failed: WebSocket opening handshake was canceled

I found documentation on the site about enabling secure websockets, but that seemed to be for when you're connecting to your own server, and you can put an SSL certificate on it. What do I need to do to get it to work?

How to fill CustomGameProperties parameter properly for createRoom?

$
0
0
We're porting our game to HTML5 and we got a problem when trying to create room. In Unity we can submit custom properties as hashtable however with Javascript SDK, we're unable to do that. For example these line of code
var opt;
opt.push("Hello", "World");
this.createRoom(null, { customGameProperties: opt });

on server customGameProperties should be a Hashtable with one element with key "Hello" and Value is "World" (if we create the room using Unity version) but instead we got a HashTable with 2 elements {"0": "Hello"} and {"1": "World"}. How can we fix the above code so we get the outcome like Unity version?

Wrong parameter type 1 (InitEncryptionRequest.ClientKey): should be Byte[] but received String.

$
0
0
Hi Supporter,
I have a questing, when i config client run with webGL, I got problem Wrong parameter type 1 (InitEncryptionRequest.ClientKey): should be Byte[] but received String.
My code client i use:

public void SendDemo(){
websocket = new WebSocket(uri);
MessageBase _m = new MessageBase ();
_f = u.ToDictionary ();
OperationRequest request = new OperationRequest ();
request.OperationCode = (byte)0;

request.Parameters = _f;
websocket.Send (SerializeInternalOperationRequest(request));
}
public byte[] SerializeInternalOperationRequest(OperationRequest operationRequest)
{
Dictionary<string, object> h1 = new Dictionary<string, object> ();
h1.Add("irq", operationRequest.OperationCode);
if (operationRequest.Parameters != null)
{
List<object> list = new List<object>(operationRequest.Parameters.Count * 2);
foreach (KeyValuePair<byte, object> pair in operationRequest.Parameters)
{
list.Add(pair.Key);
list.Add(pair.Value);
}
h1.Add("vals", list);
}
return GetMessage(h1);
}
private static byte[] GetMessage(IDictionary h)
{
JsonSerializer serializer = new JsonSerializer();
serializer.NullValueHandling = NullValueHandling.Ignore;
StringBuilder sb = new StringBuilder();
using (StringWriter writer = new StringWriter(sb))
{

using (var jsonTextWriter = new JsonTextWriter(writer))
{
serializer.Serialize (jsonTextWriter, h);

}

writer.Flush();
}
string s = string.Format("~m~{0}~m~~j~{1}", sb.Length + 3, sb);
return Encoding.UTF8.GetBytes(s);
}

How to connect to localserver by app name using javascript SDK

$
0
0
Hello !
Using Unity or .Net , I use appname parameter to connect to my gameserver, when use javascript SDK : class PhotonPeer has only connect method without parameter. How do I connect to my application by app name in javaScript SDK ?

how to create a script folder

$
0
0
I would like to know how to create a script folder

Convert PhotonPeer.RegisterType from C# Code to js

$
0
0
I'm using Unity C# with Photon server for my mobile game, and i am register custom type by PhotonPeer.RegisterType. Now i want to build a web client, using HTML5 and js, use same server with mobile client. I was parse my C# code to js code success, but dont know how to use PhotonPeer.RegisterType in js, please help me to solve it. thanks.

JS CreateRoom plugins

$
0
0
I'm trying to create new room by js sdk 4.0.0.5

In docuentation says I can set plugin name in room options by
roomOptions.Plugins = new string[]

But I don't see it in photon-javascript_SDK.js-file
LoadBalancingClient.prototype.createRoom = function (roomName, options)

I'm trying to put
createRoom("name", {plugins: "MyPlugin"})
or
createRoom("name", {customGameProperties: {plugins: "MyPlugin"}})
but it's not work

My factory is

public IGamePlugin Create(IPluginHost gameHost, string pluginName, Dictionary<string, string> config, out string errorMsg)
{
gameHost.LogWarning("!!!: > " + pluginName + " <<");

IGamePlugin plugin;
switch (pluginName)
{
case "MyPlugin":
plugin = new MyPlugin();
break;
default:
plugin = new PluginBase(); // default
break;
}
return plugin.SetupInstance(gameHost, config, out errorMsg) ? plugin : null;
}
always empty in pluginName. Am I doing something wrong?
Viewing all 162 articles
Browse latest View live