@@ -37,6 +37,16 @@ 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+
4050 public class ChannelsAPI : BaseAPI
4151 {
4252 public event Action < Channel , PlayerAlias , string > OnMessageReceived ;
@@ -113,39 +123,57 @@ public async Task<Channel[]> GetSubscribedChannels(GetSubscribedChannelsOptions
113123 return res . channels ;
114124 }
115125
116- private async Task < Channel > SendCreateChannelRequest (
117- string name ,
118- bool autoCleanup = false ,
119- bool isPrivate = false ,
120- params ( string , string ) [ ] propTuples
121- )
126+ private async Task < Channel > SendCreateChannelRequest ( CreateChannelOptions options )
122127 {
123128 Talo . IdentityCheck ( ) ;
124129
125- var props = propTuples . Select ( ( propTuple ) => new Prop ( propTuple ) ) . ToArray ( ) ;
130+ var props = options . props . Select ( ( propTuple ) => new Prop ( propTuple ) ) . ToArray ( ) ;
126131
127132 var uri = new Uri ( baseUrl ) ;
128133 var content = JsonUtility . ToJson ( new ChannelsCreateRequest
129134 {
130- name = name ,
131- autoCleanup = autoCleanup ,
135+ name = options . name ,
136+ autoCleanup = options . autoCleanup ,
132137 props = props ,
133- @private = isPrivate
138+ @private = options . isPrivate ,
139+ temporaryMembership = options . temporaryMembership
134140 } ) ;
135141 var json = await Call ( uri , "POST" , content ) ;
136142
137143 var res = JsonUtility . FromJson < ChannelResponse > ( json ) ;
138144 return res . channel ;
139145 }
140146
147+ public async Task < Channel > Create ( CreateChannelOptions options )
148+ {
149+ options ??= new CreateChannelOptions ( ) ;
150+ return await SendCreateChannelRequest ( options ) ;
151+ }
152+
153+ [ Obsolete ( "Use Create(CreateChannelOptions options) instead." ) ]
141154 public async Task < Channel > Create ( string name , bool autoCleanup = false , params ( string , string ) [ ] propTuples )
142155 {
143- return await SendCreateChannelRequest ( name , autoCleanup , false , propTuples ) ;
156+ var options = new CreateChannelOptions
157+ {
158+ name = name ,
159+ autoCleanup = autoCleanup ,
160+ props = propTuples ,
161+ isPrivate = false
162+ } ;
163+ return await SendCreateChannelRequest ( options ) ;
144164 }
145165
166+ [ Obsolete ( "Use Create(CreateChannelOptions options) instead." ) ]
146167 public async Task < Channel > CreatePrivate ( string name , bool autoCleanup = false , params ( string , string ) [ ] propTuples )
147168 {
148- return await SendCreateChannelRequest ( name , autoCleanup , true , propTuples ) ;
169+ var options = new CreateChannelOptions
170+ {
171+ name = name ,
172+ autoCleanup = autoCleanup ,
173+ props = propTuples ,
174+ isPrivate = true
175+ } ;
176+ return await SendCreateChannelRequest ( options ) ;
149177 }
150178
151179 public async Task < Channel > Join ( int channelId )
0 commit comments