ajout du service de messages
This commit is contained in:
@@ -58,10 +58,10 @@ export class UsersService extends BaseService {
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
* @param options additional options
|
||||
*/
|
||||
public createUserEndpoint(knotsDTOUserCreateUserDto: KnotsDTOUserCreateUserDto, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<KnotsDTOUserGetUserDto>;
|
||||
public createUserEndpoint(knotsDTOUserCreateUserDto: KnotsDTOUserCreateUserDto, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<KnotsDTOUserGetUserDto>>;
|
||||
public createUserEndpoint(knotsDTOUserCreateUserDto: KnotsDTOUserCreateUserDto, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<KnotsDTOUserGetUserDto>>;
|
||||
public createUserEndpoint(knotsDTOUserCreateUserDto: KnotsDTOUserCreateUserDto, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||
public createUserEndpoint(knotsDTOUserCreateUserDto: KnotsDTOUserCreateUserDto, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json' | 'application/problem+json', context?: HttpContext, transferCache?: boolean}): Observable<KnotsDTOUserGetUserDto>;
|
||||
public createUserEndpoint(knotsDTOUserCreateUserDto: KnotsDTOUserCreateUserDto, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json' | 'application/problem+json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<KnotsDTOUserGetUserDto>>;
|
||||
public createUserEndpoint(knotsDTOUserCreateUserDto: KnotsDTOUserCreateUserDto, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json' | 'application/problem+json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<KnotsDTOUserGetUserDto>>;
|
||||
public createUserEndpoint(knotsDTOUserCreateUserDto: KnotsDTOUserCreateUserDto, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json' | 'application/problem+json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||
if (knotsDTOUserCreateUserDto === null || knotsDTOUserCreateUserDto === undefined) {
|
||||
throw new Error('Required parameter knotsDTOUserCreateUserDto was null or undefined when calling createUserEndpoint.');
|
||||
}
|
||||
@@ -69,7 +69,8 @@ export class UsersService extends BaseService {
|
||||
let localVarHeaders = this.defaultHeaders;
|
||||
|
||||
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
|
||||
'application/json'
|
||||
'application/json',
|
||||
'application/problem+json'
|
||||
]);
|
||||
if (localVarHttpHeaderAcceptSelected !== undefined) {
|
||||
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
// chat.service.ts
|
||||
import * as signalR from '@microsoft/signalr';
|
||||
import {Injectable} from "@angular/core";
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class ChatService {
|
||||
|
||||
private hub: signalR.HubConnection;
|
||||
|
||||
constructor() {
|
||||
this.hub = new signalR.HubConnectionBuilder()
|
||||
.withUrl('https://localhost:5001/hubs/chat')
|
||||
.withAutomaticReconnect() // reconnexion auto si coupure réseau
|
||||
.build();
|
||||
}
|
||||
|
||||
async connect() {
|
||||
await this.hub.start();
|
||||
}
|
||||
|
||||
async joinConversation(conversationId: string) {
|
||||
await this.hub.invoke('JoinConversation', conversationId);
|
||||
}
|
||||
|
||||
async sendMessage(conversationId: string, content: string) {
|
||||
await this.hub.invoke('SendMessage', conversationId, content);
|
||||
}
|
||||
|
||||
// Écouter les messages entrants
|
||||
onMessage(callback: (msg: any) => void) {
|
||||
this.hub.on('ReceiveMessage', callback);
|
||||
}
|
||||
|
||||
// Écouter l'indicateur de frappe
|
||||
onTyping(callback: (userId: string) => void) {
|
||||
this.hub.on('UserTyping', callback);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user