Skip to content
Snippets Groups Projects
Commit 983c618c authored by L4168's avatar L4168
Browse files

added socket message

parent e144ac52
No related branches found
No related tags found
2 merge requests!59Development to master,!44Development to testing
...@@ -6,6 +6,7 @@ import { DrawService } from './draw.service'; ...@@ -6,6 +6,7 @@ import { DrawService } from './draw.service';
import { MapDrawingEntity } from '../draw/coordinate.entity'; import { MapDrawingEntity } from '../draw/coordinate.entity';
import { FactionEntity } from '../faction/faction.entity'; import { FactionEntity } from '../faction/faction.entity';
import { Game_PersonEntity } from '../game/game.entity'; import { Game_PersonEntity } from '../game/game.entity';
import { NotificationModule } from 'src/notifications/notifications.module';
/* /*
Draw Draw
- contains everything to do with mapdrawing data. - contains everything to do with mapdrawing data.
...@@ -17,6 +18,7 @@ Draw ...@@ -17,6 +18,7 @@ Draw
FactionEntity, FactionEntity,
Game_PersonEntity, Game_PersonEntity,
]), ]),
NotificationModule,
], ],
controllers: [DrawController], controllers: [DrawController],
providers: [DrawService], providers: [DrawService],
......
...@@ -4,17 +4,22 @@ import { Repository } from 'typeorm'; ...@@ -4,17 +4,22 @@ import { Repository } from 'typeorm';
import { MapDrawingEntity } from '../draw/coordinate.entity'; import { MapDrawingEntity } from '../draw/coordinate.entity';
import { MapDrawingDTO, ReturnDrawingsDTO } from './mapdrawing.dto'; import { MapDrawingDTO, ReturnDrawingsDTO } from './mapdrawing.dto';
import { NotificationGateway } from 'src/notifications/notifications.gateway';
@Injectable() @Injectable()
export class DrawService { export class DrawService {
constructor( constructor(
@InjectRepository(MapDrawingEntity) @InjectRepository(MapDrawingEntity)
private mapDrawingRepository: Repository<MapDrawingEntity>, private mapDrawingRepository: Repository<MapDrawingEntity>,
private notificationGateway: NotificationGateway,
) {} ) {}
async draw(gameId, data: MapDrawingDTO) { async draw(gameId, data: MapDrawingDTO) {
data['gameId'] = gameId; data['gameId'] = gameId;
const drawing = await this.mapDrawingRepository.create(data); const drawing = await this.mapDrawingRepository.create(data);
this.notificationGateway.server.emit(gameId, {
type: 'drawing-update',
});
if (data.mapDrawingId == null || data.mapDrawingId == '') { if (data.mapDrawingId == null || data.mapDrawingId == '') {
// luo uuden instanssin. // luo uuden instanssin.
const mapDrawing = await this.mapDrawingRepository.insert(drawing); const mapDrawing = await this.mapDrawingRepository.insert(drawing);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment