Skip to content

Commit d2b56dc

Browse files
committedFeb 18, 2017
Unify match create and join result entities. Merge heroiclabs#31
1 parent 09de0cc commit d2b56dc

File tree

3 files changed

+24
-23
lines changed

3 files changed

+24
-23
lines changed
 

‎CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ All notable changes to this project are documented below.
44
The format is based on [keep a changelog](http://keepachangelog.com/) and this project uses [semantic versioning](http://semver.org/).
55

66
## [Unreleased]
7+
### Changed
8+
- Update response types to realtime match create/join operations.
79

810
## [0.11.2] - 2017-02-17
911
### Added

‎server/api.proto

+12-17
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,14 @@ message Envelope {
123123
TMatchLeave match_leave = 43;
124124
TMatchDataSend match_data_send = 44;
125125
TMatch match = 45;
126-
TMatchPresences match_presences = 46;
127-
MatchData match_data = 47;
128-
MatchPresence match_presence = 48;
129-
130-
TStorageFetch storage_fetch = 49;
131-
TStorageWrite storage_write = 50;
132-
TStorageRemove storage_remove = 51;
133-
TStorageData storage_data = 52;
134-
TStorageKey storage_key = 53;
126+
MatchData match_data = 46;
127+
MatchPresence match_presence = 47;
128+
129+
TStorageFetch storage_fetch = 48;
130+
TStorageWrite storage_write = 49;
131+
TStorageRemove storage_remove = 50;
132+
TStorageData storage_data = 51;
133+
TStorageKey storage_key = 52;
135134
}
136135
}
137136

@@ -403,17 +402,13 @@ message TopicPresence {
403402
}
404403

405404
message TMatchCreate {}
406-
message TMatch {
407-
bytes id = 1;
408-
UserPresence self = 2;
409-
}
410-
411405
message TMatchJoin {
412406
bytes match_id = 1;
413407
}
414-
message TMatchPresences {
415-
repeated UserPresence presences = 1;
416-
UserPresence self = 2;
408+
message TMatch {
409+
bytes match_id = 1;
410+
repeated UserPresence presences = 2;
411+
UserPresence self = 3;
417412
}
418413

419414
message TMatchDataSend {

‎server/pipeline_match.go

+10-6
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,15 @@ func (p *pipeline) matchCreate(logger zap.Logger, session *session, envelope *En
2424

2525
p.tracker.Track(session.id, "match:"+matchID.String(), session.userID, PresenceMeta{})
2626

27+
self := &UserPresence{
28+
UserId: session.userID.Bytes(),
29+
SessionId: session.id.Bytes(),
30+
}
31+
2732
session.Send(&Envelope{CollationId: envelope.CollationId, Payload: &Envelope_Match{Match: &TMatch{
28-
Id: matchID.Bytes(),
29-
Self: &UserPresence{
30-
UserId: session.userID.Bytes(),
31-
SessionId: session.id.Bytes(),
32-
},
33+
MatchId: matchID.Bytes(),
34+
Presences: []*UserPresence{self},
35+
Self: self,
3336
}}})
3437
}
3538

@@ -64,7 +67,8 @@ func (p *pipeline) matchJoin(logger zap.Logger, session *session, envelope *Enve
6467
}
6568
userPresences[len(ps)-1] = self
6669

67-
session.Send(&Envelope{CollationId: envelope.CollationId, Payload: &Envelope_MatchPresences{MatchPresences: &TMatchPresences{
70+
session.Send(&Envelope{CollationId: envelope.CollationId, Payload: &Envelope_Match{Match: &TMatch{
71+
MatchId: matchIDBytes,
6872
Presences: userPresences,
6973
Self: self,
7074
}}})

0 commit comments

Comments
 (0)
Please sign in to comment.