separated socket from app for clear develoopement
This commit is contained in:
parent
0a504a75ce
commit
9889600708
8 changed files with 129 additions and 52 deletions
|
|
@ -130,6 +130,43 @@ export interface SigninRequest {
|
|||
*/
|
||||
export class OpenapiOtherApi extends runtime.BaseAPI {
|
||||
|
||||
/**
|
||||
*/
|
||||
async apiChatSocketIoGetRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
|
||||
const queryParameters: any = {};
|
||||
|
||||
const headerParameters: runtime.HTTPHeaders = {};
|
||||
|
||||
|
||||
let urlPath = `/api/chat/socket.io`;
|
||||
|
||||
const response = await this.request({
|
||||
path: urlPath,
|
||||
method: 'GET',
|
||||
headers: headerParameters,
|
||||
query: queryParameters,
|
||||
}, initOverrides);
|
||||
|
||||
// CHANGED: Handle all status codes defined in the OpenAPI spec, not just 2xx responses
|
||||
// This allows typed access to error responses (4xx, 5xx) and other status codes.
|
||||
// The code routes responses based on the actual HTTP status code and returns
|
||||
// appropriately typed ApiResponse wrappers for each status code.
|
||||
if (response.status === 200) {
|
||||
// No body response for status 200
|
||||
return new runtime.VoidApiResponse(response);
|
||||
}
|
||||
// CHANGED: Throw error if status code is not handled by any of the defined responses
|
||||
// This ensures all code paths return a value and provides clear error messages for unexpected status codes
|
||||
// Only throw if responses were defined but none matched the actual status code
|
||||
throw new runtime.ResponseError(response, `Unexpected status code: ${response.status}. Expected one of: 200`);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
async apiChatSocketIoGet(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
|
||||
await this.apiChatSocketIoGetRaw(initOverrides);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
async chatTestRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ChatTest200Response | StatusOtp401Response>> {
|
||||
|
|
|
|||
|
|
@ -74,6 +74,11 @@
|
|||
text-center z-50;
|
||||
}
|
||||
|
||||
.mainboxDisplay button {
|
||||
@apply
|
||||
cursor-pointer;
|
||||
}
|
||||
|
||||
p {
|
||||
@apply
|
||||
text-black
|
||||
|
|
|
|||
|
|
@ -8,23 +8,32 @@ import io from "socket.io-client";
|
|||
|
||||
// const socket = io("wss://localhost:8888");
|
||||
|
||||
const socket = io("wss://local.maix.me:8888", {
|
||||
const socket = io("wss://localhost:8888", {
|
||||
path: "/api/chat/socket.io/",
|
||||
secure: true,
|
||||
secure: false,
|
||||
transports: ["websocket"],
|
||||
});
|
||||
|
||||
// Listen for the 'connect' event
|
||||
socket.on("connect", async () => {
|
||||
console.log("Connected to the server: ", socket.id);
|
||||
console.log("I AM Connected to the server: ", socket.id);
|
||||
// Emit a custom event 'coucou' with some data
|
||||
socket.emit("coucou", { message: "Hello Nigel from coucou!" });
|
||||
console.log('sent coucou');
|
||||
console.log('sent console.log coucou');
|
||||
// Send a message to the server
|
||||
socket.send("Hello from the client: " + `${socket.id}`);
|
||||
});
|
||||
|
||||
|
||||
// Listen for messages from the server
|
||||
socket.on("MsgObjectServer", (data) => {
|
||||
console.log("Message from server:", data);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
type Providers = {
|
||||
name: string,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue