Skip to content

kibibites/cs2-presence

Repository files navigation

cs2 presence

discord rich presence for counter strike 2.

preview

preview image

download

platform link
windows latest | nightly
linux latest | nightly

usage

  1. download either the executable from the section above.

  2. extract and run the executable, and start your game.

    • note: you must start the program before you launch the game for the first time; then, the order of you starting does not matter anymore.
  3. visit http://localhost:8000 to change preferences.

api

this server only handles POST requests from cs2, it does not have any other http apis. all client-server communications are over websockets at ws://localhost:8000/ws.

heartbeat

const ping = new Uint8Array([0xe2, 0x99, 0xa1]);
const pong = new Uint8Array([0xe2, 0x99, 0xa5]);

after client connects to the server, it must send pings at least every 3-4 seconds to avoid time out.

the server will reply with pong.

sync

export interface Activity {
  details: string;
  state?: string;
  assets: {
    large_image: string;
    large_text: string;
  };
  timestamps: {
    start: number;
  };
}

const sync = new Uint8Array([0xe2, 0x87, 0x8b, ...encodeCbor(obj satisfies Activity)])

the server will send clients sync messages, formatted like above, whenever there is an activity update.

saving options

interface Options {
  timeout: number;
  fluffy: boolean;
  disableFluffy: boolean;
}

const options = new Uint8Array([0xe2, 0x9a, 0x99, ...encodeCbor(obj satisfies Options)])

the clients can send the server options messages to update the options.

Sponsor this project

Packages

 
 
 

Contributors