@@ -37,11 +37,27 @@ public string ToQueryString()
3737 }
3838 }
3939
40+ public class CreateChannelOptions
41+ {
42+ public string name ;
43+ public ( string , string ) [ ] props = Array . Empty < ( string , string ) > ( ) ;
44+
45+ public bool autoCleanup = false ;
46+ public bool isPrivate = false ;
47+ public bool temporaryMembership = false ;
48+ }
49+
50+ public enum ChannelLeavingReason
51+ {
52+ Default ,
53+ TemporaryMembership
54+ }
55+
4056 public class ChannelsAPI : BaseAPI
4157 {
4258 public event Action < Channel , PlayerAlias , string > OnMessageReceived ;
4359 public event Action < Channel , PlayerAlias > OnChannelJoined ;
44- public event Action < Channel , PlayerAlias > OnChannelLeft ;
60+ public event Action < Channel , PlayerAlias , ChannelLeavingReason > OnChannelLeft ;
4561 public event Action < Channel , PlayerAlias > OnOwnershipTransferred ;
4662 public event Action < Channel > OnChannelDeleted ;
4763 public event Action < Channel , string [ ] > OnChannelUpdated ;
@@ -63,7 +79,7 @@ public ChannelsAPI() : base("v1/game-channels")
6379 else if ( response . GetResponseType ( ) == "v1.channels.left" )
6480 {
6581 var data = response . GetData < ChannelLeftResponse > ( ) ;
66- OnChannelLeft ? . Invoke ( data . channel , data . playerAlias ) ;
82+ OnChannelLeft ? . Invoke ( data . channel , data . playerAlias , data . meta . reason ) ;
6783 }
6884 else if ( response . GetResponseType ( ) == "v1.channels.ownership-transferred" )
6985 {
@@ -113,39 +129,57 @@ public async Task<Channel[]> GetSubscribedChannels(GetSubscribedChannelsOptions
113129 return res . channels ;
114130 }
115131
116- private async Task < Channel > SendCreateChannelRequest (
117- string name ,
118- bool autoCleanup = false ,
119- bool isPrivate = false ,
120- params ( string , string ) [ ] propTuples
121- )
132+ private async Task < Channel > SendCreateChannelRequest ( CreateChannelOptions options )
122133 {
123134 Talo . IdentityCheck ( ) ;
124135
125- var props = propTuples . Select ( ( propTuple ) => new Prop ( propTuple ) ) . ToArray ( ) ;
136+ var props = options . props . Select ( ( propTuple ) => new Prop ( propTuple ) ) . ToArray ( ) ;
126137
127138 var uri = new Uri ( baseUrl ) ;
128139 var content = JsonUtility . ToJson ( new ChannelsCreateRequest
129140 {
130- name = name ,
131- autoCleanup = autoCleanup ,
141+ name = options . name ,
142+ autoCleanup = options . autoCleanup ,
132143 props = props ,
133- @private = isPrivate
144+ @private = options . isPrivate ,
145+ temporaryMembership = options . temporaryMembership
134146 } ) ;
135147 var json = await Call ( uri , "POST" , content ) ;
136148
137149 var res = JsonUtility . FromJson < ChannelResponse > ( json ) ;
138150 return res . channel ;
139151 }
140152
153+ public async Task < Channel > Create ( CreateChannelOptions options )
154+ {
155+ options ??= new CreateChannelOptions ( ) ;
156+ return await SendCreateChannelRequest ( options ) ;
157+ }
158+
159+ [ Obsolete ( "Use Create(CreateChannelOptions options) instead." ) ]
141160 public async Task < Channel > Create ( string name , bool autoCleanup = false , params ( string , string ) [ ] propTuples )
142161 {
143- return await SendCreateChannelRequest ( name , autoCleanup , false , propTuples ) ;
162+ var options = new CreateChannelOptions
163+ {
164+ name = name ,
165+ autoCleanup = autoCleanup ,
166+ props = propTuples ,
167+ isPrivate = false
168+ } ;
169+ return await SendCreateChannelRequest ( options ) ;
144170 }
145171
172+ [ Obsolete ( "Use Create(CreateChannelOptions options) instead." ) ]
146173 public async Task < Channel > CreatePrivate ( string name , bool autoCleanup = false , params ( string , string ) [ ] propTuples )
147174 {
148- return await SendCreateChannelRequest ( name , autoCleanup , true , propTuples ) ;
175+ var options = new CreateChannelOptions
176+ {
177+ name = name ,
178+ autoCleanup = autoCleanup ,
179+ props = propTuples ,
180+ isPrivate = true
181+ } ;
182+ return await SendCreateChannelRequest ( options ) ;
149183 }
150184
151185 public async Task < Channel > Join ( int channelId )
0 commit comments