Commit d2b56dc0 authored by Andrei Mihu's avatar Andrei Mihu
Browse files

Unify match create and join result entities. Merge #31

parent 09de0cc5
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -4,6 +4,8 @@ All notable changes to this project are documented below.
The format is based on [keep a changelog](http://keepachangelog.com/) and this project uses [semantic versioning](http://semver.org/).

## [Unreleased]
### Changed
- Update response types to realtime match create/join operations.

## [0.11.2] - 2017-02-17
### Added
+12 −17
Original line number Diff line number Diff line
@@ -123,15 +123,14 @@ message Envelope {
    TMatchLeave match_leave = 43;
    TMatchDataSend match_data_send = 44;
    TMatch match = 45;
    TMatchPresences match_presences = 46;
    MatchData match_data = 47;
    MatchPresence match_presence = 48;
    MatchData match_data = 46;
    MatchPresence match_presence = 47;

    TStorageFetch storage_fetch = 49;
    TStorageWrite storage_write = 50;
    TStorageRemove storage_remove = 51;
    TStorageData storage_data = 52;
    TStorageKey storage_key = 53;
    TStorageFetch storage_fetch = 48;
    TStorageWrite storage_write = 49;
    TStorageRemove storage_remove = 50;
    TStorageData storage_data = 51;
    TStorageKey storage_key = 52;
  }
}

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

message TMatchCreate {}
message TMatch {
  bytes id = 1;
  UserPresence self = 2;
}

message TMatchJoin {
  bytes match_id = 1;
}
message TMatchPresences {
  repeated UserPresence presences = 1;
  UserPresence self = 2;
message TMatch {
  bytes match_id = 1;
  repeated UserPresence presences = 2;
  UserPresence self = 3;
}

message TMatchDataSend {
+10 −6
Original line number Diff line number Diff line
@@ -24,12 +24,15 @@ func (p *pipeline) matchCreate(logger zap.Logger, session *session, envelope *En

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

	session.Send(&Envelope{CollationId: envelope.CollationId, Payload: &Envelope_Match{Match: &TMatch{
		Id: matchID.Bytes(),
		Self: &UserPresence{
	self := &UserPresence{
		UserId:    session.userID.Bytes(),
		SessionId: session.id.Bytes(),
		},
	}

	session.Send(&Envelope{CollationId: envelope.CollationId, Payload: &Envelope_Match{Match: &TMatch{
		MatchId:   matchID.Bytes(),
		Presences: []*UserPresence{self},
		Self:      self,
	}}})
}

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

	session.Send(&Envelope{CollationId: envelope.CollationId, Payload: &Envelope_MatchPresences{MatchPresences: &TMatchPresences{
	session.Send(&Envelope{CollationId: envelope.CollationId, Payload: &Envelope_Match{Match: &TMatch{
		MatchId:   matchIDBytes,
		Presences: userPresences,
		Self:      self,
	}}})