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

Connecting server with playfab

$
0
0
I am trying to realtime cloud server with playfab (JavaScript API).
Using appID generated by playfab, I can get Photon Authentication Token, but I have no idea how to setCustomAuthentication.

Below code results in "Client: Error: 3101 NameServer authentication failed"
var client = new Photon.LoadBalancing.LoadBalancingClient(Photon.ConnectionProtocol.Ws, APPID, "1.0");
var authParam = "username=user1" + "&token=" + TOKEN;
client.setCustomAuthentication(authParam, Photon.LoadBalancing.Constants.CustomAuthenticationType.Custom);
client.connectToRegionMaster("EU");

Can anybody help me?

Where can I learn to use Photon plugin for Construct 2?

$
0
0
There isn't a great deal of documentation or support available and I'm wondering how I can learn it. I'm struggling every step of the way.

Please help.

Thanks!

Connecting to Photon Cloud from Node.js or .Net Core

$
0
0
Hi,

As much as I searched I couldn't find the JavaScript Client SDK to download, even though there were links on the Photon website.
Also I was wandering if anybody tried to use this SDK from Node.js. I'm assuming that it should work if you do some changes.
One more thing, I know that there is C# Client SDK for Photon, does anyone know if there are plans to make it work with .Net Core?

Thanks in advance guys.

Hope it makes sense what I've written.

Get photon for JS using npm

Error logging in with facebook in the SDK demos

$
0
0
Hello, I'm trying to develop multiplayer for a HTML5 game and I'm just testing stuff in photon; the examples are great and everything seemed ready to go until I tried to login via FaceBook.
So I set up the facebook provider in the app's details - both appID and secretID are set.
Next I add the appID in the cloud-app-info.js file for the demo-particle, clear cache and cookies and refresh the demo.
The FB login button shows up and all seems okay, I hit the button, authorize the app in the popup and.. I get this error in the demo : Error 1101 Master authentication failed .
The user seems logged into facebook, the picture and name show up instead of the login button now, but it doesn't look like the user is logged in correctly; if I refresh the page I get the same error (same thing happens with in demo-loadbalancing, although the error is slightly different: Error 3101: NameServer authentication failed )
Help please ! :smile:

Here's a cutoff from the browser console (can't post the whole thing, is't too big apparently):

Demo: State: Uninitialized -> ConnectingToMasterserver Photon-Javascript_SDK.js:679:37
Demo: Connecting to Master ws://app-eu.exitgamescloud.com:9090 Photon-Javascript_SDK.js:679:37
Master: PhotonPeer[_addListener] - Adding listener for event error Photon-Javascript_SDK.js:679:37
...
Master: PhotonPeer[_addListener] - Adding listener for event 219 Photon-Javascript_SDK.js:679:37
Master: PhotonPeer[_onConnecting] - Starts connecting ws://app-eu.exitgamescloud.com:9090 ..., raising "connecting" event ... Photon-Javascript_SDK.js:679:37
Master: PhotonPeer[_onConnect] - Connected successfully! Raising "connect" event ... Photon-Javascript_SDK.js:679:37
Master: Connected Photon-Javascript_SDK.js:679:37
Master: PhotonPeer[sendOperation] - Sending request: {"req":230,"vals":[224,"6ec13d29-8b09-4f21-99b5-d9207ec9c137",220,"1.0",217,0,216,"token=EAADCXWxVxxABAAu5p7emsnwSV5kmGZCWqk2ZC1tQLqZAj2N5Y8ZCkcXkf7w6CWFjVlFSxZC2p9QUSd44ZAdBuagdZCbUwADZB1VJsXojzBG4NJxxjPBYMuuhZCvXoza2ZAaXmlrHHiQP7QStRoQztidhkAP4Xa4VQWz6ZCUCGKG2gaMFVSPZCW7BbtbenxuaFsHpfB8bLLF9cKARRAZDZD"]} Photon-Javascript_SDK.js:679:37
Master: Authenticate... Photon-Javascript_SDK.js:679:37
Master: PhotonPeer[_onMessageReceived] - Socket received message: {"err":32755,"res":230,"msg":"Authentication type not supported"} Photon-Javascript_SDK.js:679:37
Master: resp Authenticate {"errCode":32755,"errMsg":"Authentication type not supported","vals":[]} Photon-Javascript_SDK.js:679:37
Demo: State: ConnectingToMasterserver -> Error Photon-Javascript_SDK.js:679:37
Demo: Error: 1101 Master authentication failed

Prefer connecting to peers on local network

$
0
0
I am new to networking and the Photon JavaScript SDK, and I haven't been able to find previous discussions on this:
I want two clients on the same local network to prefer connecting to eachother instead of connecting to clients on separate networks. I am aware that all client communication run through a regional cloud server. Self-hosted server is not an option, since I want to connect mobile devices.

It seems Bolt might be the solution for this, but no Bolt SDK currently exists for C2 which is my engine of choice for this project.
Is this at all achievable through the Realtime JavaScript SDK (or some other way)?
Thanks!

RoomProperty with Construct2

$
0
0
I can't get custom properties to work, maybe I missed something.

When a player joins or leave I do:
Set custom property "team1" of my room to Team1Count
Set custom property "team2" of my room to Team2Count

When I log to console int(Photon.PropertyOfMyRoom("team1")) I get the correct value.

When I get the room list I want to check team1 and team2 values before joining a room.
Now I'm trying to get the properties with Photon.RoomProperty function.
I do a System.Repeat on Photon.RoomCount
and tried to log
int(Photon.RoomProperty(Photon.RoomNameAt(loopindex), "team1"))
or
int(Photon.RoomProperty("team1", Photon.RoomNameAt(loopindex)))
but I always get 0.

Are the parameters wrong or is it something else?
Thanks a lot!

weird ERROR => "1002+Master peer connect failed: ws://SLAMS070.exitgames.com:9090" HELP

$
0
0
I'm on Construct2
and this error is only happening when I'm trying to export my game with node.js .
Because yes , as an html file or as an app (apk/android) it work ,
but not when I'm exporting with node.js ,
I've tried to change to wss, to change of server ,
I've tried to search everywhere but I think I'm the only one with this weird error ...

could someone help me?

it's the error 1002
Master peer connect failed: ws://SLAMS070.exitgames.com:9090

Why addResponseListener callback not work?

$
0
0
It's right to get response data in ResponseListener's callback function ? Or I think wrong ?

here is my code :
const addListener = (client) => {
    client.addResponseListener(CODE,(e) => { console.log('addResponseListener callback',e.data) } );
}
But nothing in console QAQ

Playfab integration

$
0
0
I have problem on API request for GetPhotonAuthenticationToken, I don't know what to put on X-Authentication, and I got this error.

code : 401
error : "NotAuthenticated"
errorCode : 1074
errorMessage : "X-Authentication HTTP header contains invalid ticket"
status : "Unauthorized"

I don't know what to do because I can't search any documentation for photon javascript and integration to playfab.
I'm a newbie here and I need help thanks :)

Fetch cached events with Node.js

$
0
0
My plan is to implement an anti-cheat into my game that's not constantly running, but players would report sketchy behaviour to my server alongside with the room id, region etc.
The server should then fetch all the events from the photon cache and process them. I obviouly can't trust any client with that task.

-- Is there any way to fetch the global/player cache from a third party?
-> I am using PUN

Thank you deeply for any help pointing me into the right direction

Custom Authentication with PlayFab fails

$
0
0
I am using Photon's JavaScript SDK.
From around January 26th, custom authentication with PlayFab came to fail.
Previously it worked fine.
The following appears on the console.

Client: Error: 3101 NameServer authentication failed

I tried to review my code again, but there was no particular problem.

Creating an IO Game, Authoritative Server Logic and Server Setup Help!

$
0
0
Its our first time making a multiplayer and we're currently making an IO type of game (where there are 100 people in a room) and we thought of using Photon because of the nice API features and the Photon Cloud services. Currently, we have a running demo using the Realtime SDk that runs the logic in the master client and can run fine with 8 to 10 people.

However, we need a dedicated server for authoritative logic and able to handle the 100 players. We were confused as how to do this.

1. We read about Photon Cloud using Webhooks since its easy as they'll handle the server hosting but we weren't sure how to apply custom server logic to it.
2. Photon Plugins are also an alternative but it says it requires Enterprise cloud or your own Photon on premises server. But, it seems to much work compared to using the Cloud.
3. We also looked into Playfab custom servers and cloud scripting but we're not sure if it even works with the Realtime SDK.

Our question is what's the best way to handle this? We're currently lost and would really like help from experienced people about this.

Thank you!

Failure: Failed to parse message header for protocol Json

$
0
0
Why always i get the error message using websocket?
Failure: Failed to parse message header for protocol Json

Can a native(c++) client and a web(JavaScript) client enter one room?

$
0
0
Two native clients can enter the room "test_room". Two web clients also see each other in this room.
But the native client and the web can not see each other's friends. Why is that?


JavaScript SDK - myRoomActors has bugs?!

$
0
0
in DemoLoadBalancing.prototype.onJoinRoom = function(){...}
call PhotonService.myRoomActors()
the first player got correct result..
but, the 2nd player get the result: (top 2 actor in map is ok,but there are 7 func-like string keys follow on)
and, room.playerCount = 9.

{1: Actor, 2: Actor, "function (el) {↵ var i;↵ for (i = 0; i < this.length; i++) {↵ if (this[i] == el) return true;↵ }↵ return false;↵}": Actor, "function () {↵ var arr = [];↵ var i = 0;↵ for (; i < this.length; i++) {↵ switch (_typeof(this[i])) {↵ case 'object':↵ var obj = {};↵ for (key in this[i]) {↵ obj[key] = this[i][key];↵ }arr.push(obj);↵ break;↵ default:↵ arr.push(this[i]);↵ break;↵ }↵ }↵ return arr;↵}": Actor, "function () {↵ this.splice(0, this.length);↵}": Actor, "function (arr) {↵ if (arr) {↵ var i;↵ for (i = 0; i < arr.length; i++) {↵ this.push(arr[i]);↵ }↵ }↵}": Actor, "function (field) {↵ var arr = [];↵↵ var i = 0;↵ for (; i < this.length; i++) {↵ var val = field ? this[i][field] : this[i];↵ var index = this.lastIndexOf(val, field);↵ if (index == i) arr.push(this[i]);↵ }↵↵ return arr;↵}": Actor, …}
1
:
Actor {name: "User958", actorNr: 1, isLocal: false, customProperties: {…}, suspended: false, …}
2
:
Actor {name: "User197", actorNr: 2, isLocal: true, customProperties: {…}, suspended: false, …}
"function () {↵ this.splice(0, this.length);↵}"
:
Actor {name: "User958", actorNr: ƒ, isLocal: false, customProperties: {…}, suspended: false, …}
"function () {↵ var arr = [];↵ var i = 0;↵ for (; i < this.length; i++) {↵ switch (_typeof(this[i])) {↵ case 'object':↵ var obj = {};↵ for (key in this[i]) {↵ obj[key] = this[i][key];↵ }arr.push(obj);↵ break;↵ default:↵ arr.push(this[i]);↵ break;↵ }↵ }↵ return arr;↵}"
:
Actor {name: "User958", actorNr: ƒ, isLocal: false, customProperties: {…}, suspended: false, …}
"function (arr) {↵ if (arr) {↵ var i;↵ for (i = 0; i < arr.length; i++) {↵ this.push(arr[i]);↵ }↵ }↵}"
:
Actor {name: "User958", actorNr: ƒ, isLocal: false, customProperties: {…}, suspended: false, …}
"function (el) {↵ var i;↵ for (i = 0; i < this.length; i++) {↵ if (this[i] == el) return true;↵ }↵ return false;↵}"
:
Actor {name: "User958", actorNr: ƒ, isLocal: false, customProperties: {…}, suspended: false, …}
"function (field) {↵ var arr = [];↵↵ var i = 0;↵ for (; i < this.length; i++) {↵ var val = field ? this[i][field] : this[i];↵ var index = this.lastIndexOf(val, field);↵ if (index == i) arr.push(this[i]);↵ }↵↵ return arr;↵}"
:
Actor {name: "User958", actorNr: ƒ, isLocal: false, customProperties: {…}, suspended: false, …}
"function (field) {↵ var result = -1;↵↵ var i = 0;↵ for (; i < this.length; i++) {↵ var val = field ? this[i][field] : this[i];↵ if (val < result) result = val;↵ }↵↵ return result;↵}"
:
Actor {name: "User958", actorNr: ƒ, isLocal: false, customProperties: {…}, suspended: false, …}
"function (field) {↵ var result = -1;↵↵ var i = 0;↵ for (; i < this.length; i++) {↵ var val = field ? this[i][field] : this[i];↵ if (val > result) result = val;↵ }↵↵ return result;↵}"
:
Actor {name: "User958", actorNr: ƒ, isLocal: false, customProperties: {…}, suspended: false, …}
__proto__
:
Object

onRoomListUpdate roomsAdded always [undefined]

$
0
0
may be there is a bug:
Photon-Javascript_SDK.js line:3354:
//roomsAdded.push(r);
roomsAdded.push(ri);

And I find that after 2 players leave a room, and one of them create a new room, the 2nd of them can't join the new room 1st&2nd&3rd..time. When try the 4th time, finally joined.

[Solved] WWS not working in cocos

$
0
0
Edit: Never mind, it turns out we need a file named cacert.pem to make it work.

Basically we're using Photon JS SDK with coco2d-x for our web client and then also use it to build for Android. The code is mostly the same and it's working on the web as well on Android. Except only ws is working. I suspect cocos2d-x doesn't support wss. But I've tried testing wss using a test website wss://echo.websocket.org:443 it seem wss is supposed to be working fine. So I'm confused not sure why Photon SDK doesn't work with wss.

Here is the log when I'm trying to connect (9090 is the port I'm using for wss):

Master: PhotonPeer[_onConnecting] - Starts connecting wss://my website:9090 ..., raising "connecting" event ...
D/WebSocket.cpp (415): WebSocket thread start, helper instance: 0x60c0002b1a00
D/WebSocket.cpp (167): NOTICE: Initial logging level 911

D/WebSocket.cpp (167): NOTICE: Libwebsockets version: 2.1.0 james@James-Chen.local-v3.4-139-gbdcf7f8

D/WebSocket.cpp (167): NOTICE: IPV6 compiled in and enabled

D/WebSocket.cpp (167): NOTICE: libev support not compiled in

D/WebSocket.cpp (167): NOTICE: libuv support not compiled in

D/WebSocket.cpp (167): NOTICE: Threads: 1 each 4864 fds

D/WebSocket.cpp (167): NOTICE: mem: platform fd map: 38912 bytes

D/WebSocket.cpp (167): NOTICE: Compiled with OpenSSL support

D/WebSocket.cpp (167): NOTICE: mem: per-conn: 512 bytes + protocol rx buf

D/WebSocket.cpp (873): scheme: wss, host: my website, port: 9090, path:
D/WebSocket.cpp (837): WARNING: CA Root file isn't set. SSL connection will not peer server certificate
D/WebSocket.cpp (167): NOTICE: Creating Vhost 'default' port -1, 1 protocols, IPv6 on

D/WebSocket.cpp (167): NOTICE: lws_protocol_init

D/WebSocket.cpp (1322): WebSocket (0x7fd438eacfd0) Unhandled websocket event: 32
D/WebSocket.cpp (1322): WebSocket (0x7fd438eacfd0) Unhandled websocket event: 29
D/WebSocket.cpp (167): ERR: server's cert didn't look good, X509_V_ERR = 20: error:00000014:lib(0):func(0):reason(20)

D/WebSocket.cpp (1197): WebSocket (0x7fd438eacfd0) onConnectionError, state: 0 ...
D/WebSocket.cpp (1226): WebSocket (0x7fd438eacfd0) onConnectionClosed, state: 2 ...
D/WebSocket.cpp (1256): onConnectionClosed, WebSocket (0x7fd438eacfd0) is closing by server.
D/WebSocket.cpp (1279): WebSocket (0x7fd438eacfd0) onConnectionClosed DONE!
D/WebSocket.cpp (1322): WebSocket (0x7fd438eacfd0) Unhandled websocket event: 45
D/WebSocket.cpp (1322): WebSocket (0x7fd438eacfd0) Unhandled websocket event: 33
D/WebSocket.cpp (1226): WebSocket (0x7fd438eacfd0) onConnectionClosed, state: 3 ...
ERROR : Master: PhotonPeer[_onError] - Connection error: {"type":"error"}
Client: State: ConnectingToMasterserver -> Error
ERROR : Client: Error: 1001 Master peer error
Client: State: Error -> Disconnected
Master: onclose: wasClean = , code= , reason =
Master: PhotonPeer[_onDisconnect] - Socket closed, raising "disconnect" event ...
D/WebSocket.cpp (545): In the destructor of WebSocket (0x7fd438eacfd0)
D/WebSocket.cpp (565): before join ws thread
D/WebSocket.cpp (167): NOTICE: lws_context_destroy

D/WebSocket.cpp (425): WebSocket thread exit, helper instance: 0x60c0002b1a00
D/WebSocket.cpp (567): after join ws thread

Note that I checked the server log and don't see any connection request.

Cross platform (Unity & JS) not working

$
0
0
Hi,
we've developed a simple game using Photon for Unity, which is working fine. We'd like to add support for cross platform HTML clients using JavaScript. Unfortunately, we can't seem to get the JavaScript clients to see the Unity ones and vice-versa.

I've gone through the matchmaking checklist:
- Both Unity and JavaScript are using the same AppID and Version
- Both are also connecting to the same master region, EU

Additionally:
- JavaScript clients can create a room, and that's seen by other JavaScript clients; the same happens between Unity clients
- Trying to connect from Unity into the JavaScript client's room by name yields a "Operation failed: OperationResponse 225: ReturnCode: 32760 (No match found)" warning

What could I still be missing here?

is there rejoin or reconnect in js-sdk?

$
0
0
when everyone is ready, main logic start, and set setIsOpen(false);
when some one offline, and i want him rejoin back. and call joinroom, but can't join because the game is closed.
if i can't set setisOpen(false), after the one offline, other player will join in. i don't want this...
Viewing all 162 articles
Browse latest View live