gros probleme resolu
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { HttpException, HttpStatus, Injectable, Res } from '@nestjs/common';
|
||||
import { WsException } from '@nestjs/websockets';
|
||||
import { WebSocketGateway, SubscribeMessage, WebSocketServer, MessageBody, ConnectedSocket, OnGatewayConnection, OnGatewayDisconnect } from '@nestjs/websockets';
|
||||
import { UsersService } from 'src/users/users.service';
|
||||
import { ChatService } from './chat.service';
|
||||
@@ -22,12 +24,16 @@ implements OnGatewayConnection, OnGatewayDisconnect
|
||||
@WebSocketServer()
|
||||
server;
|
||||
|
||||
async handleConnection(socket: socketDto) {
|
||||
async handleConnection(socket: socketDto)
|
||||
{
|
||||
printCaller('- socket connected :', socket.id, socket.handshake.query.username);
|
||||
|
||||
socket.username = socket.handshake.query.username.toString();
|
||||
this.sockets.set(socket.username, socket);
|
||||
|
||||
if (!socket.username)
|
||||
return;
|
||||
|
||||
this.sockets.set(socket.username, socket);
|
||||
printCaller("--- socket.username:", socket.username);
|
||||
|
||||
let not_emit: string = `${socket.username}_not_emit`;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
{#if ($location !== '/')}
|
||||
<Header/>
|
||||
{/if}
|
||||
|
||||
<Chat />
|
||||
|
||||
<Router routes={primaryRoutes} on:conditionsFailed={conditionsFailed}/>
|
||||
|
||||
@@ -60,7 +60,8 @@ function start_after_countdown()
|
||||
window.addEventListener(
|
||||
'keydown',
|
||||
(e) => {
|
||||
e.preventDefault();
|
||||
if (e.key === "ArrowUp" || e.key === "ArrowDown")
|
||||
e.preventDefault();
|
||||
pong.addKey(e.key);
|
||||
},
|
||||
{signal: abortControllerKeydown.signal}
|
||||
@@ -70,7 +71,8 @@ function start_after_countdown()
|
||||
window.addEventListener(
|
||||
'keyup',
|
||||
(e) => {
|
||||
e.preventDefault();
|
||||
if (e.key === "ArrowUp" || e.key === "ArrowDown")
|
||||
e.preventDefault();
|
||||
pong.deleteKey(e.key);
|
||||
},
|
||||
{signal: abortControllerKeyup.signal}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import Layouts from './Chat_layouts.svelte';
|
||||
import { init_socket } from './Socket_chat';
|
||||
import { user } from './Store_chat';
|
||||
import { location } from 'svelte-spa-router';
|
||||
|
||||
let style_light =
|
||||
@@ -40,8 +41,8 @@
|
||||
bg_light_color: "rgb( 35, 35, 35)",
|
||||
|
||||
btn_color: "rgb(220, 220, 220)",
|
||||
btn_color_hover: "rgb(100, 100, 100)",
|
||||
btn_color_active: "rgb( 90, 90, 90)",
|
||||
btn_color_hover: "rgb(160, 160, 160)",
|
||||
btn_color_active: "rgb(150, 150, 150)",
|
||||
btn_color_border: "rgb(150, 150, 150)",
|
||||
|
||||
btn_light_color: "rgb(235, 235, 235)",
|
||||
@@ -61,10 +62,6 @@
|
||||
|
||||
let style = style_light;
|
||||
|
||||
console.log("location:",$location);
|
||||
if ($location !== '/')
|
||||
init_socket();
|
||||
|
||||
function change_style(loc)
|
||||
{
|
||||
console.log("change color, location:", loc);
|
||||
@@ -78,7 +75,16 @@
|
||||
style = style_light;
|
||||
}
|
||||
|
||||
$: change_style($location);
|
||||
init_socket();
|
||||
|
||||
$: change_style($location);
|
||||
$: {
|
||||
$location;
|
||||
if (!user)
|
||||
{
|
||||
init_socket();
|
||||
};
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -239,11 +239,11 @@ export async function remove_block_user(username: string): Promise<void>
|
||||
await fetch_chat_request('unblock', FetchMethod.POST, {username: username} );
|
||||
}
|
||||
|
||||
export async function list_block_user(username: string): Promise<string[]>
|
||||
export async function list_block_user(username: string): Promise<User[]>
|
||||
{
|
||||
to_print("in list_block_user");
|
||||
|
||||
let response = await fetch_chat_request('listblock', FetchMethod.GET);
|
||||
let response: FetchResponse = await fetch_chat_request('listblock', FetchMethod.GET);
|
||||
to_print("response.users:", response.users);
|
||||
|
||||
return response.users;
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
import io from 'socket.io-client';
|
||||
import { user, msgs, layout, set_socket, set_user } from './Store_chat';
|
||||
import { to_print } from './Utils_chat';
|
||||
import { fetchUser } from '../utils';
|
||||
|
||||
const address = `http://${process.env.WEBSITE_HOST}:${process.env.WEBSITE_PORT}`;
|
||||
|
||||
export async function init_socket()
|
||||
{
|
||||
to_print("in init_socket");
|
||||
console.log("here");
|
||||
const response = await fetch(`${address}/api/v2/user`);
|
||||
const response_data = await response.json();
|
||||
to_print("-- response_data:", response_data);
|
||||
const user = await fetchUser();
|
||||
if (!user)
|
||||
return;
|
||||
|
||||
set_user(response_data);
|
||||
set_user(user);
|
||||
|
||||
let socket = await io(address,
|
||||
{
|
||||
path: '/chat',
|
||||
query:
|
||||
{
|
||||
username: response_data.username,
|
||||
username: user.username,
|
||||
},
|
||||
});
|
||||
console.log("horo");
|
||||
|
||||
set_socket(socket);
|
||||
|
||||
socket_states(socket);
|
||||
|
||||
Reference in New Issue
Block a user