async Task IReadModifyWriteObject.Refresh() { Channel = await Server.GetChannelState(Channel.id); LinkedChannels.Clear(); foreach (var chan in Channel.links) { LinkedChannels.Add(new ChannelShim(Server, chan)); } }
public override async Task ChannelRemoved(Murmur.Channel chan) { using (var context = await FancyContext.Connect()) { var channel = await context.Channels.Where(x => x.ServerId == chan.id).SingleAsync(); channel.ServerId = null; context.ChannelInfoChanges.Add(new Channel.InfoChange { Channel = channel, Name = null, Description = null, When = DateTimeOffset.Now, }); await context.SaveChangesAsync(); } }
public override async Task ChannelStateChanged(Murmur.Channel chan) { using (var context = await FancyContext.Connect()) { var query = from channel in context.Channels where channel.ServerId == chan.id join ichange in context.ChannelInfoChanges on channel.Id equals ichange.Channel.Id into infoChanges select new { channel, parentId = channel.Parent.ServerId, name = infoChanges.OrderByDescending(x => x.When).Select(x => x.Name).Where(x => x != null).FirstOrDefault(), desc = infoChanges.OrderByDescending(x => x.When).Select(x => x.Description).Where(x => x != null).FirstOrDefault(), }; var res = await query.SingleAsync(); var infoChange = new Channel.InfoChange { Channel = res.channel, Name = chan.name == res.name ? null : chan.name, Description = chan.description == res.desc ? null : chan.description, When = DateTimeOffset.Now, }; if (res.parentId != chan.parent) { res.channel.Parent = await context.Channels.Where(x => x.ServerId == chan.parent).SingleAsync(); } if (infoChange.Name != null || infoChange.Description != null) { context.ChannelInfoChanges.Add(infoChange); } await context.SaveChangesAsync(); } }
public override async Task ChannelCreated(Murmur.Channel chan) { using (var context = await FancyContext.Connect()) using (var transact = context.Database.BeginTransaction()) { var dbchan = context.Channels.Add(new Channel { Temporary = chan.temporary, Parent = await context.Channels.Where(x => x.ServerId == chan.parent).SingleAsync(), ServerId = chan.id, }); context.ChannelInfoChanges.Add(new Channel.InfoChange { Channel = dbchan, Name = chan.name, Description = chan.description, When = DateTimeOffset.Now }); await context.SaveChangesAsync(); transact.Commit(); } }
public static void write(IceInternal.BasicStream os__, _System.Collections.Generic.Dictionary<int, Murmur.Channel> v__) { if(v__ == null) { os__.writeSize(0); } else { os__.writeSize(v__.Count); foreach(_System.Collections.Generic.KeyValuePair<int, Murmur.Channel> e__ in v__) { os__.writeInt(e__.Key); if(e__.Value == null) { Murmur.Channel tmp__ = new Murmur.Channel(); tmp__.write__(os__); } else { e__.Value.write__(os__); } } } }
public static Murmur.Channel[] read(IceInternal.BasicStream is__) { Murmur.Channel[] v__; { int szx__ = is__.readSize(); is__.startSeq(szx__, 16); v__ = new Murmur.Channel[szx__]; for(int ix__ = 0; ix__ < szx__; ++ix__) { v__[ix__] = new Murmur.Channel(); v__[ix__].read__(is__); is__.checkSeq(); is__.endElement(); } is__.endSeq(szx__); } return v__; }
public static _System.Collections.Generic.Dictionary<int, Murmur.Channel> read(IceInternal.BasicStream is__) { int sz__ = is__.readSize(); _System.Collections.Generic.Dictionary<int, Murmur.Channel> r__ = new _System.Collections.Generic.Dictionary<int, Murmur.Channel>(); for(int i__ = 0; i__ < sz__; ++i__) { int k__; k__ = is__.readInt(); Murmur.Channel v__; v__ = null; if(v__ == null) { v__ = new Murmur.Channel(); } v__.read__(is__); r__[k__] = v__; } return r__; }
public override Task ChannelCreated(Murmur.Channel chan) { var apiChannel = new ChannelWrapper(WServer, chan); return(Task.WhenAll(Plugins.Select(x => x.OnChannelCreated(apiChannel)))); }
public override void write__(IceInternal.BasicStream os__) { os__.writeTypeId(ice_staticId()); os__.startWriteSlice(); if(c == null) { Murmur.Channel tmp__ = new Murmur.Channel(); tmp__.write__(os__); } else { c.write__(os__); } if(children == null) { os__.writeSize(0); } else { os__.writeSize(children.Length); for(int ix__ = 0; ix__ < children.Length; ++ix__) { os__.writeObject(children[ix__]); } } if(users == null) { os__.writeSize(0); } else { os__.writeSize(users.Length); for(int ix__ = 0; ix__ < users.Length; ++ix__) { (users[ix__] == null ? new Murmur.User() : users[ix__]).write__(os__); } } os__.endWriteSlice(); base.write__(os__); }
public override void getChannelState_async(Murmur.AMD_Server_getChannelState cb__, int channelid, Ice.Current current__) { Murmur.Channel ret__ = new Murmur.Channel(); cb__.ice_response(ret__); }
public override void channelRemoved(Murmur.Channel state, Ice.Current current__) { }
public static Ice.DispatchStatus channelStateChanged___(ServerCallback obj__, IceInternal.Incoming inS__, Ice.Current current__) { checkMode__(Ice.OperationMode.Idempotent, current__.mode); IceInternal.BasicStream is__ = inS__.istr(); is__.startReadEncaps(); Murmur.Channel state; state = null; if(state == null) { state = new Murmur.Channel(); } state.read__(is__); is__.endReadEncaps(); obj__.channelStateChanged(state, current__); return Ice.DispatchStatus.DispatchOK; }
public static Ice.DispatchStatus setChannelState___(Server obj__, IceInternal.Incoming inS__, Ice.Current current__) { checkMode__(Ice.OperationMode.Idempotent, current__.mode); IceInternal.BasicStream is__ = inS__.istr(); is__.startReadEncaps(); Murmur.Channel state; state = null; if(state == null) { state = new Murmur.Channel(); } state.read__(is__); is__.endReadEncaps(); AMD_Server_setChannelState cb__ = new _AMD_Server_setChannelState(inS__); try { obj__.setChannelState_async(cb__, state, current__); } catch(_System.Exception ex__) { cb__.ice_exception(ex__); } return Ice.DispatchStatus.DispatchAsync; }
public sealed override void channelStateChanged_async(Murmur.AMD_ServerCallback_channelStateChanged cb__, Murmur.Channel state, Ice.Current current__) { cb__.ice_response(); AsyncCompleter(ChannelStateChanged(state)); }
public Task SetChannelState(Murmur.Channel state) { return(FixIce.FromAsyncVoid(state, S.begin_setChannelState, S.end_setChannelState)); }
public virtual Task ChannelStateChanged(Murmur.Channel chan) { return(NullTask); }
public virtual Task ChannelRemoved(Murmur.Channel chan) { return(NullTask); }
public virtual Task ChannelCreated(Murmur.Channel chan) { return(NullTask); }
public void channelStateChanged(Murmur.Channel state, _System.Collections.Generic.Dictionary<string, string> context__) { IceInternal.Outgoing og__ = handler__.getOutgoing("channelStateChanged", Ice.OperationMode.Idempotent, context__); try { try { IceInternal.BasicStream os__ = og__.ostr(); if(state == null) { Murmur.Channel tmp__ = new Murmur.Channel(); tmp__.write__(os__); } else { state.write__(os__); } } catch(Ice.LocalException ex__) { og__.abort(ex__); } bool ok__ = og__.invoke(); if(!og__.istr().isEmpty()) { try { if(!ok__) { try { og__.throwUserException(); } catch(Ice.UserException ex__) { throw new Ice.UnknownUserException(ex__.ice_name(), ex__); } } og__.istr().skipEmptyEncaps(); } catch(Ice.LocalException ex__) { throw new IceInternal.LocalExceptionWrapper(ex__, false); } } } finally { handler__.reclaimOutgoing(og__); } }
public static Murmur.Channel[] read(IceInternal.BasicStream is__) { Murmur.Channel[] v__; { int szx__ = is__.readAndCheckSeqSize(16); v__ = new Murmur.Channel[szx__]; for(int ix__ = 0; ix__ < szx__; ++ix__) { v__[ix__] = new Murmur.Channel(); v__[ix__].read__(is__); } } return v__; }
public Murmur.Channel getChannelState(int channelid, _System.Collections.Generic.Dictionary<string, string> context__) { IceInternal.Outgoing og__ = handler__.getOutgoing("getChannelState", Ice.OperationMode.Idempotent, context__); try { try { IceInternal.BasicStream os__ = og__.ostr(); os__.writeInt(channelid); } catch(Ice.LocalException ex__) { og__.abort(ex__); } bool ok__ = og__.invoke(); try { if(!ok__) { try { og__.throwUserException(); } catch(Murmur.InvalidChannelException) { throw; } catch(Murmur.ServerBootedException) { throw; } catch(Ice.UserException ex__) { throw new Ice.UnknownUserException(ex__.ice_name(), ex__); } } IceInternal.BasicStream is__ = og__.istr(); is__.startReadEncaps(); Murmur.Channel ret__; ret__ = null; if(ret__ == null) { ret__ = new Murmur.Channel(); } ret__.read__(is__); is__.endReadEncaps(); return ret__; } catch(Ice.LocalException ex__) { throw new IceInternal.LocalExceptionWrapper(ex__, false); } } finally { handler__.reclaimOutgoing(og__); } }
public Murmur.Channel end_getChannelState(Ice.AsyncResult r__) { IceInternal.OutgoingAsync outAsync__ = (IceInternal.OutgoingAsync)r__; IceInternal.OutgoingAsync.check__(outAsync__, this, __getChannelState_name); if(!outAsync__.wait__()) { try { outAsync__.throwUserException__(); } catch(Murmur.InvalidChannelException) { throw; } catch(Murmur.InvalidSecretException) { throw; } catch(Murmur.ServerBootedException) { throw; } catch(Ice.UserException ex__) { throw new Ice.UnknownUserException(ex__.ice_name(), ex__); } } Murmur.Channel ret__; IceInternal.BasicStream is__ = outAsync__.istr__; is__.startReadEncaps(); ret__ = null; if(ret__ == null) { ret__ = new Murmur.Channel(); } ret__.read__(is__); is__.endReadEncaps(); return ret__; }
public override void setChannelState_async(Murmur.AMD_Server_setChannelState cb__, Murmur.Channel state, Ice.Current current__) { cb__.ice_response(); }
public override void read__(IceInternal.BasicStream is__, bool rid__) { if(rid__) { /* string myId = */ is__.readTypeId(); } is__.startReadSlice(); if(c == null) { c = new Murmur.Channel(); } c.read__(is__); { int szx__ = is__.readSize(); is__.startSeq(szx__, 4); children = new Murmur.Tree[szx__]; for(int ix__ = 0; ix__ < szx__; ++ix__) { IceInternal.ArrayPatcher<Murmur.Tree> spx = new IceInternal.ArrayPatcher<Murmur.Tree>("::Murmur::Tree", children, ix__); is__.readObject(spx); is__.checkSeq(); is__.endElement(); } is__.endSeq(szx__); } { int szx__ = is__.readSize(); is__.startSeq(szx__, 42); users = new Murmur.User[szx__]; for(int ix__ = 0; ix__ < szx__; ++ix__) { users[ix__] = new Murmur.User(); users[ix__].read__(is__); is__.checkSeq(); is__.endElement(); } is__.endSeq(szx__); } is__.endReadSlice(); base.read__(is__, true); }
public void ice_response(Murmur.Channel ret__) { if(validateResponse__(true)) { try { IceInternal.BasicStream os__ = this.os__(); if(ret__ == null) { Murmur.Channel tmp__ = new Murmur.Channel(); tmp__.write__(os__); } else { ret__.write__(os__); } } catch(Ice.LocalException ex__) { ice_exception(ex__); } response__(true); } }
private Ice.AsyncResult<Murmur.Callback_ServerCallback_channelStateChanged> begin_channelStateChanged(Murmur.Channel state, _System.Collections.Generic.Dictionary<string, string> ctx__, bool explicitContext__, Ice.AsyncCallback cb__, object cookie__) { IceInternal.OnewayOutgoingAsync<Murmur.Callback_ServerCallback_channelStateChanged> result__ = new IceInternal.OnewayOutgoingAsync<Murmur.Callback_ServerCallback_channelStateChanged>(this, __channelStateChanged_name, channelStateChanged_completed__, cookie__); if(cb__ != null) { result__.whenCompletedWithAsyncCallback(cb__); } try { result__.prepare__(__channelStateChanged_name, Ice.OperationMode.Idempotent, ctx__, explicitContext__); IceInternal.BasicStream os__ = result__.ostr__; if(state == null) { Murmur.Channel tmp__ = new Murmur.Channel(); tmp__.write__(os__); } else { state.write__(os__); } os__.endWriteEncaps(); result__.send__(true); } catch(Ice.LocalException ex__) { result__.exceptionAsync__(ex__); } return result__; }
public Tree(Murmur.Channel c, Murmur.Tree[] children, Murmur.User[] users) { this.c = c; this.children = children; this.users = users; }
public ChannelWrapper(Wrapped.Server server, Murmur.Channel channel) : base(server, channel.id) { Channel = channel; LinkedChannels = new HashSet <IChannelShim>(channel.links.Select(x => new ChannelShim(server, x))); }