Skip to content

Conversation

@cqmpact
Copy link

@cqmpact cqmpact commented Dec 4, 2025

Goal of this PR

This PR introduces WebSocket support to the Cfx.re framework by implementing native socket functionality and exposing it through scripting APIs. This enables resource developers to create real-time bidirectional communication channels with external services.

How is this PR achieving the goal

This PR achieves the goal through two main changes:

  1. Core WebSocket Implementation (feat(scripting-core): websockets): Implements the underlying WebSocket functionality in the scripting core, providing the foundational infrastructure for socket connections.

  2. Native Declarations (add(native-decls): socket declarations): Adds the native declarations/bindings that expose the WebSocket functionality to scripting runtimes, making the feature accessible to resource developers across different scripting languages.

This PR applies to the following area(s)

  • FiveM
  • RedM
  • LibertyM
  • Server
  • Natives
  • ScRT: Lua
  • ScRT: C#
  • ScRT: JS

Successfully tested on

Game builds: b3258

Platforms: Windows

Checklist

  • Code compiles and has been tested successfully.
  • Code explains itself well and/or is documented.
  • My commit message explains what the changes do and what they are for.
  • No extra compilation warnings are added by these changes.

Example

local socketId = SocketConnect("ws://localhost:8080", function(eventType, data)
    print("WebSocket event: " .. eventType)
    if eventType == "message" then
        print("Received: " .. data)
    elseif eventType == "error" then
        print("Error: " .. data)
    end
end)

if socketId > 0 then
    print("WebSocket connected with ID: " .. socketId)
    SocketSend(socketId, "Hello, Server!")
else
    print("Failed to connect to WebSocket server.")
end

Success:
image

Fail:
image

@github-actions github-actions bot added the invalid Requires changes before it's considered valid and can be (re)triaged label Dec 4, 2025
@cqmpact cqmpact changed the title Add WebSocket support to client resources add(citizen-scripting-core): WebSocket support Dec 4, 2025
@radium-cfx radium-cfx added status:deferred Action on this has been deferred to a later time and removed invalid Requires changes before it's considered valid and can be (re)triaged labels Dec 4, 2025
@radium-cfx
Copy link
Contributor

Thanks for your work on this change! Unfortunately, we’re currently in a feature freeze for FiveM, so we’re unable to merge any changes that modify or extend our APIs at this time.

@cqmpact
Copy link
Author

cqmpact commented Dec 4, 2025

Thanks for your work on this change! Unfortunately, we’re currently in a feature freeze for FiveM, so we’re unable to merge any changes that modify or extend our APIs at this time.

No problem, and that's really unfortunate to hear.
I hope that the freeze doesn't last too long!
Thanks for the feedback.

@SSnowly
Copy link

SSnowly commented Dec 4, 2025

Aint gonna be mean but if we are in a feature freeze why aren't the issues being fixed?
On another note this is an amazing feature that should be in cfx by default! Good work!

@lLukDreams
Copy link

Probably to reduce stuff they need to migrate to a new platform ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:deferred Action on this has been deferred to a later time

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants