OLD | NEW |
| (Empty) |
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | |
2 // for details. All rights reserved. Use of this source code is governed by a | |
3 // BSD-style license that can be found in the LICENSE.md file. | |
4 | |
5 library fletchc.verbs.end_verb; | |
6 | |
7 import 'infrastructure.dart'; | |
8 | |
9 import '../hub/session_manager.dart' show | |
10 endSession; | |
11 | |
12 import 'documentation.dart' show | |
13 endDocumentation; | |
14 | |
15 const Action endAction = | |
16 const Action(end, endDocumentation, requiresTargetSession: true); | |
17 | |
18 Future<int> end(AnalyzedSentence sentence, VerbContext context) { | |
19 String name = sentence.targetName; | |
20 UserSession session = endSession(name); | |
21 context = context.copyWithSession(session); | |
22 return session.worker.performTask( | |
23 new EndSessionTask(name), context.clientConnection, endSession: true); | |
24 } | |
25 | |
26 class EndSessionTask extends SharedTask { | |
27 // Keep this class simple, see note in superclass. | |
28 | |
29 final String name; | |
30 | |
31 const EndSessionTask(this.name); | |
32 | |
33 Future<int> call( | |
34 CommandSender commandSender, | |
35 StreamIterator<ClientCommand> commandIterator) { | |
36 return endSessionTask(name); | |
37 } | |
38 } | |
39 | |
40 Future<int> endSessionTask(String name) { | |
41 assert(SessionState.internalCurrent.name == name); | |
42 SessionState.internalCurrent = null; | |
43 print("Ended session '$name'."); | |
44 return new Future<int>.value(0); | |
45 } | |
OLD | NEW |