Added Connection Component, Store, JWT logic
This commit is contained in:
@@ -3,10 +3,15 @@ import { socket } from "../(dispatch)/socket";
|
||||
|
||||
console.log("connectionStore");
|
||||
|
||||
export const connectionStore = create((set) => ({
|
||||
interface ConnectionStore {
|
||||
isConnected: boolean;
|
||||
connect: (uid: string) => Promise<void>;
|
||||
}
|
||||
|
||||
export const connectionStore = create<ConnectionStore>((set) => ({
|
||||
isConnected: false,
|
||||
connect: async (jwt: string) => {
|
||||
socket.auth = { token: "jwt" };
|
||||
connect: async (uid: string) => {
|
||||
socket.auth = { uid };
|
||||
socket.connect();
|
||||
},
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user