WebSocket location server/client map thing

WebSocket location server/client map thing

in API Development

Posted by: zeeZ.5713

zeeZ.5713

Code: https://github.com/zeeZ/gw2-location
Map: http://dl.dropboxusercontent.com/u/6664141/gw2/map.html
“Binaries”: https://dl.dropboxusercontent.com/u/6664141/gw2/location_dist.zip

Right now it’s a very basic implementation and due to lack of free time won’t move at much speed, but I welcome any pull requests.

It consists of three things:
location_sender uses the MumbleLink data GW2 provides and based on an API call translates your map coordinates to world coordinates, then opens a WebSocket to location_distributor and continually sends it your position

location_distributor takes that data, does a minimal amount of sanity checking, puts it into a big list and provides a second WebSocket which the map can connect to, to perpetually receive a list of players and their location

map… well, is a basic map to show that data. Right now it doesn’t allow to change address and key on the fly, so you’d have to download and change it if you want to mess with different servers and keys.

Both location_sender and map provide a key on connect to allow for grouping. The map will only receive location data for players that have provided the same key.

You can sort of demo it by running location_sender.{exe/py} local.ctrl-alt-chainsaw.net
With both sender and map not providing a key I sort of consider that a public group :P

WebSocket location server/client map thing

in API Development

Posted by: vanzan.1250

vanzan.1250

Code: https://github.com/zeeZ/gw2-location
Map: http://dl.dropboxusercontent.com/u/6664141/gw2/map.html
“Binaries”: https://dl.dropboxusercontent.com/u/6664141/gw2/location_dist.zip

Right now it’s a very basic implementation and due to lack of free time won’t move at much speed, but I welcome any pull requests.

It consists of three things:
location_sender uses the MumbleLink data GW2 provides and based on an API call translates your map coordinates to world coordinates, then opens a WebSocket to location_distributor and continually sends it your position

location_distributor takes that data, does a minimal amount of sanity checking, puts it into a big list and provides a second WebSocket which the map can connect to, to perpetually receive a list of players and their location

map… well, is a basic map to show that data. Right now it doesn’t allow to change address and key on the fly, so you’d have to download and change it if you want to mess with different servers and keys.

Both location_sender and map provide a key on connect to allow for grouping. The map will only receive location data for players that have provided the same key.

You can sort of demo it by running location_sender.{exe/py} local.ctrl-alt-chainsaw.net
With both sender and map not providing a key I sort of consider that a public group :P

Looks great, I think from a WvW perspective being able to see our guild and what they are doing is invaluable.

What would be great is if everyone could see green dots like those of your allies and a blue dot for the leader of your raid.

Do I run location distributor on my server forward the ports add a key to it and then host the webpage with the distributor address and key for it to work like this?

WebSocket location server/client map thing

in API Development

Posted by: zeeZ.5713

zeeZ.5713

Do I run location distributor on my server forward the ports add a key to it and then host the webpage with the distributor address and key for it to work like this?

The distributor doesn’t care about the keys really, all you set it up with is a port and update frequency (no binding to a specific interface yet, sorry).

You’d set it and a map modified for your needs up somewhere, give your people the sender and point them to it.

Ideally you’d have a prompt for the key on both sender and map, so if a third party knew where your map was they’d not get your locations.

For ease of use give them the sender as an exe and a preconfigured bat along with it to run that thing, like:


@echo off
set /P key="Enter key: " %=%
location_sender.exe local.ctrl-alt-chainsaw.net -l info -p 8888 -f 0.5 -k %key%
pause

They’d enter it as they run the bat and open the map, and off they go. Or you hard code it on the map and/or client and hope nobody from the other side figures out where your map is

As for the icon, line 144 sets the icon style for a new player, which is defined in 105-110.
You could define a new icon, like “leaderIcon” along with a list of your leaders, like “var leaders = [‘Gir Doomsong’,‘Inventor Zim’];” somewhere, and modify line 144 to read something like “icon: leaders.indexOf(player.name)>=0? leaderIcon : posIcon,” or something :P

I should definitely update the map a little if I get around to….

WebSocket location server/client map thing

in API Development

Posted by: DarkSpirit.7046

DarkSpirit.7046

It can be useful if you provide short documentations on how we can communicate with your server if we decide to write our own client.

(edited by DarkSpirit.7046)

WebSocket location server/client map thing

in API Development

Posted by: zeeZ.5713

zeeZ.5713

As of right now, what’s being sent is basically this:

Client output:

{
“map”: int map_id,
“continent”: int continent_id,
“name”: string character name,
“face”: float face direction in degrees,
“elevation”: float adjusted elevation,
“position”: [float adjusted x, float adjusted y]
}
encoded in Base64.

map_id is bytes 27 and 28 from context as uint32 (counting from 0), I believe
continent_id is from https://api.guildwars2.com/v1/maps.json?map_id=… (cache that thing on every map change)
name is identity
face is -(atan2(fAvatarFront[ 2 ], fAvatarFront[ 0 ])*180/pi)%360
elevation is fAvatarPosition[ 1 ]*39.3701
position is fAvatarPosition[ 0 , 2 ]*39.3701, then transformed from map coordinates to continent coordinates

Server output:

[{client 1}, {client 2}, …]
unencoded…

Client connets to: ws://host/publish/key
Map connects to: ws://host/players.json/key

There is no other fancy stuff being done on connect other than what simple WebSockets do.

The server will accept more data than the above minimum, but will simply discard it.

(edited by zeeZ.5713)

WebSocket location server/client map thing

in API Development

Posted by: DarkSpirit.7046

DarkSpirit.7046

Thanks zeeZ!

And I presume your server is listening at local.ctrl-alt-chainsaw.net:8888.

(edited by DarkSpirit.7046)

WebSocket location server/client map thing

in API Development

Posted by: Edgar Doiron.2804

Edgar Doiron.2804

Thanks
I hosted it on my website last night, works flawlessly

Forgeman Destroyers [FORD] – Sorrows furnace