summaryrefslogtreecommitdiff
path: root/shared/src/main/java/kz/ilotterytea/frogartha/domain/events/IdentifiedEvent.java
blob: 01a12fe2aae06d50d95a0a14dd700c534adcafa0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package kz.ilotterytea.frogartha.domain.events;

import com.github.czyzby.websocket.serialization.SerializationException;
import com.github.czyzby.websocket.serialization.Transferable;
import com.github.czyzby.websocket.serialization.impl.Deserializer;
import com.github.czyzby.websocket.serialization.impl.Serializer;
import kz.ilotterytea.frogartha.domain.Identity;

public class IdentifiedEvent extends Event implements Transferable<IdentifiedEvent> {
    private Identity identity;

    public IdentifiedEvent() {
    }

    public IdentifiedEvent(int playerId, Identity identity) {
        super(playerId);
        this.identity = identity;
    }

    public Identity getIdentity() {
        return identity;
    }

    @Override
    public void serialize(Serializer serializer) throws SerializationException {
        serializer.serializeInt(playerId).serializeTransferable(identity);
    }

    @Override
    public IdentifiedEvent deserialize(Deserializer deserializer) throws SerializationException {
        return new IdentifiedEvent(deserializer.deserializeInt(), deserializer.deserializeTransferable(new Identity()));
    }
}