Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HLTV has changed its websocket endpoint #42

Open
mrwhale opened this issue Nov 7, 2018 · 0 comments
Open

HLTV has changed its websocket endpoint #42

mrwhale opened this issue Nov 7, 2018 · 0 comments

Comments

@mrwhale
Copy link

mrwhale commented Nov 7, 2018

Hey @andrewda
Been a while since I've used this library, but getting back into it it seems that hltv has upgraded its websocket endpoint and a few other bits and pieces during the connecting. I've played around to see how it works now and pretty sure I've got it - but will need some help integrating that back into this library

In this I was using the websocat command line client to test and connect
Endpoint - scorebot-secure.hltv.org

  1. websocat "wss://scorebot-secure.hltv.org/socket.io/?EIO=3&transport=websocket"
    • On connection you will get some information back such as an sid
  2. Echo to the server 61:42["readyForMatch","{\"token\":\"\",\"listId\":\"2328874\"}"]
  • You should immediately start getting live matchin information
  1. every so ofter you should echo back a "keep alive" of 2, the server will respond with 3. if you do not receive a response generally means the connection has closed
    Below is a print of it in action, and a look at the data structure of the json feed that it returs
mrwhale@mrwhale:~$ websocat "wss://scorebot-secure.hltv.org/socket.io/?EIO=3&transport=websocket"
0{"sid":"b347b8ad-86ab-4a67-9ef6-eb120dde1e63","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":60000}
40
>> 61:42["readyForMatch","{\"token\":\"\",\"listId\":\"2328874\"}"]
42["scoreboard",{"TERRORIST":[{"steamId":"1:1:13560020","dbId":7993,"name":"bvd. Detrony","score":26,"deaths":17,"assists":5,"alive":false,"money":100,"damagePrRound":103.48275862068965,"hp":0,"kevlar":false,"helmet":false,"nick":"Detrony","hasDefusekit":false},{"steamId":"1:0:90746920","dbId":10611,"name":"bvd. Fadey","score":26,"deaths":24,"assists":5,"alive":false,"money":950,"damagePrRound":94.44827586206897,"hp":0,"kevlar":false,"helmet":false,"nick":"Fadey","hasDefusekit":false},{"steamId":"1:0:30724686","dbId":11630,"name":"bvd. JT^","score":21,"deaths":20,"assists":9,"alive":true,"money":300,"damagePrRound":83.20689655172414,"hp":73,"primaryWeapon":"ak47","kevlar":true,"helmet":true,"nick":"JT","hasDefusekit":false},{"steamId":"1:1:8352209","dbId":8446,"name":"bvd. ELUS1VE","score":15,"deaths":17,"assists":1,"alive":true,"money":200,"damagePrRound":49.827586206896555,"hp":100,"primaryWeapon":"galilar","kevlar":true,"helmet":true,"nick":"ELUSIVE","hasDefusekit":false},{"steamId":"1:1:7432061","dbId":8711,"name":"bvd. Sonic^","score":14,"deaths":21,"assists":3,"alive":true,"money":0,"damagePrRound":48.793103448275865,"hp":70,"primaryWeapon":"ak47","kevlar":true,"helmet":true,"nick":"Sonic","hasDefusekit":false}],"CT":[{"steamId":"1:1:59654408","dbId":16647,"name":"INF_bwills","score":25,"deaths":18,"assists":3,"alive":true,"money":3550,"damagePrRound":77.10344827586206,"hp":100,"primaryWeapon":"ak47","kevlar":true,"helmet":true,"nick":"Bwills","hasDefusekit":true},{"steamId":"1:0:11946443","dbId":9342,"name":"INF_JoshRT","score":24,"deaths":20,"assists":5,"alive":false,"money":7850,"damagePrRound":89.48275862068965,"hp":0,"kevlar":false,"helmet":false,"nick":"JoshRT","hasDefusekit":false},{"steamId":"1:0:28414483","dbId":13261,"name":"INF_tweiss","score":20,"deaths":21,"assists":4,"alive":false,"money":2700,"damagePrRound":74.82758620689656,"hp":0,"kevlar":false,"helmet":false,"nick":"tweiss","hasDefusekit":false},{"steamId":"1:1:60979592","dbId":13307,"name":"INF_Strings","score":17,"deaths":23,"assists":4,"alive":true,"money":3600,"damagePrRound":68.03448275862068,"hp":100,"primaryWeapon":"m4a1","kevlar":true,"helmet":true,"nick":"Strings","hasDefusekit":true},{"steamId":"1:1:458376","dbId":9301,"name":"INF_real_bM","score":12,"deaths":20,"assists":4,"alive":true,"money":6450,"damagePrRound":64.72413793103448,"hp":65,"primaryWeapon":"m4a1","kevlar":true,"helmet":true,"nick":"real_bM","hasDefusekit":true}],"ctMatchHistory":{"firstHalf":[{"type":"Terrorists_Win","roundOrdinal":1,"survivingPlayers":5},{"type":"Terrorists_Win","roundOrdinal":2,"survivingPlayers":3},{"type":"Target_Bombed","roundOrdinal":3,"survivingPlayers":0},{"type":"Target_Bombed","roundOrdinal":4,"survivingPlayers":4},{"type":"lost","roundOrdinal":5,"survivingPlayers":0},{"type":"lost","roundOrdinal":6,"survivingPlayers":0},{"type":"lost","roundOrdinal":7,"survivingPlayers":0},{"type":"Terrorists_Win","roundOrdinal":8,"survivingPlayers":1},{"type":"Terrorists_Win","roundOrdinal":9,"survivingPlayers":2},{"type":"Terrorists_Win","roundOrdinal":10,"survivingPlayers":4},{"type":"Target_Bombed","roundOrdinal":11,"survivingPlayers":1},{"type":"lost","roundOrdinal":12,"survivingPlayers":0},{"type":"lost","roundOrdinal":13,"survivingPlayers":0},{"type":"lost","roundOrdinal":14,"survivingPlayers":0},{"type":"lost","roundOrdinal":15,"survivingPlayers":0}],"secondHalf":[{"type":"CTs_Win","roundOrdinal":16,"survivingPlayers":1},{"type":"CTs_Win","roundOrdinal":17,"survivingPlayers":1},{"type":"Bomb_Defused","roundOrdinal":18,"survivingPlayers":1},{"type":"lost","roundOrdinal":19,"survivingPlayers":0},{"type":"lost","roundOrdinal":20,"survivingPlayers":2},{"type":"lost","roundOrdinal":21,"survivingPlayers":1},{"type":"CTs_Win","roundOrdinal":22,"survivingPlayers":2},{"type":"lost","roundOrdinal":23,"survivingPlayers":1},{"type":"lost","roundOrdinal":24,"survivingPlayers":0},{"type":"lost","roundOrdinal":25,"survivingPlayers":0},{"type":"CTs_Win","roundOrdinal":26,"survivingPlayers":3},{"type":"CTs_Win","roundOrdinal":27,"survivingPlayers":3},{"type":"CTs_Win","roundOrdinal":28,"survivingPlayers":5}]},"terroristMatchHistory":{"firstHalf":[{"type":"lost","roundOrdinal":1,"survivingPlayers":0},{"type":"lost","roundOrdinal":2,"survivingPlayers":0},{"type":"lost","roundOrdinal":3,"survivingPlayers":1},{"type":"lost","roundOrdinal":4,"survivingPlayers":0},{"type":"CTs_Win","roundOrdinal":5,"survivingPlayers":4},{"type":"CTs_Win","roundOrdinal":6,"survivingPlayers":3},{"type":"CTs_Win","roundOrdinal":7,"survivingPlayers":3},{"type":"lost","roundOrdinal":8,"survivingPlayers":0},{"type":"lost","roundOrdinal":9,"survivingPlayers":0},{"type":"lost","roundOrdinal":10,"survivingPlayers":0},{"type":"lost","roundOrdinal":11,"survivingPlayers":2},{"type":"Bomb_Defused","roundOrdinal":12,"survivingPlayers":1},{"type":"CTs_Win","roundOrdinal":13,"survivingPlayers":3},{"type":"CTs_Win","roundOrdinal":14,"survivingPlayers":5},{"type":"CTs_Win","roundOrdinal":15,"survivingPlayers":5}],"secondHalf":[{"type":"lost","roundOrdinal":16,"survivingPlayers":0},{"type":"lost","roundOrdinal":17,"survivingPlayers":0},{"type":"lost","roundOrdinal":18,"survivingPlayers":0},{"type":"Terrorists_Win","roundOrdinal":19,"survivingPlayers":3},{"type":"Target_Bombed","roundOrdinal":20,"survivingPlayers":3},{"type":"Target_Bombed","roundOrdinal":21,"survivingPlayers":2},{"type":"lost","roundOrdinal":22,"survivingPlayers":0},{"type":"Target_Bombed","roundOrdinal":23,"survivingPlayers":3},{"type":"Terrorists_Win","roundOrdinal":24,"survivingPlayers":3},{"type":"Terrorists_Win","roundOrdinal":25,"survivingPlayers":2},{"type":"lost","roundOrdinal":26,"survivingPlayers":0},{"type":"lost","roundOrdinal":27,"survivingPlayers":0},{"type":"lost","roundOrdinal":28,"survivingPlayers":0}]},"bombPlanted":false,"mapName":"de_nuke","terroristTeamName":"Bravado","ctTeamName":"Infamous","currentRound":29,"counterTerroristScore":15,"terroristScore":13,"ctTeamId":9379,"tTeamId":5158,"frozen":false,"live":true,"ctTeamScore":15,"tTeamScore":13}]
42["log","{\"log\":[{\"Kill\":{\"killerName\":\"bvd. JT^\",\"killerNick\":\"JT\",\"killerSide\":\"TERRORIST\",\"victimNick\":\"tweiss\",\"victimName\":\"INF_tweiss\",\"victimSide\":\"CT\",\"weapon\":\"ak47\",\"headShot\":true}}]}"]

>> 2
3
.......

You also get some useful things during the round such as
42["log","{\"log\":[{\"MatchStarted\":{\"map\":\"de_nuke\"}}]}"]
42["log","{\"log\":[{\"MatchStarted\":{\"map\":\"de_nuke\"}}]}"]

You can also submit the string
61:42["readyForScores","{\"token\":\"\",\"listIds\":[2328874]}"] to the server to get a nice summary of the match
42["score",{"mapScores":{"1":{"firstHalf":{"ctTeamDbId":5158,"ctScore":8,"tTeamDbId":9379,"tScore":7},"secondHalf":{"ctTeamDbId":9379,"ctScore":8,"tTeamDbId":5158,"tScore":6},"overtime":{"ctTeamDbId":9379,"ctScore":0,"tTeamDbId":5158,"tScore":0},"mapOrdinal":1,"scores":{"9379":15,"5158":14},"currentCtId":9379,"currentTId":5158,"map":"de_nuke","mapOver":false}},"listId":2328874,"wins":{},"liveLog":{"":true,"IrregularTeamKillsRequirement":true,"PlayersRequirement":false,"NoSuspectEventsInFirstRoundRequirement":false,"NotKnifeRoundRequirement":true,"BombInPlayRequirement":false,"KillsInFirstRoundRequirement":false,"FiveKillsWhenEnemyElliminatedRequirement less than 5 five kills in round(s) []":true,"MatchStartRequirement":true,"MapNameRequirement":true,"NoDrawRoundsRequirement":true,"FirstRoundOverRequirement":false,"RoundOneMaxEquipmentValueRequirement":true},"forcedLive":false,"forcedDead":false}]

It seems with this method you can list a number of matchId's and get an entire summary back (this is how the main page of HLTV keeps updated for all live matches

Let me know if I can help testing. If I do get some time I may submit a PR for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant