Commit d9969c36 authored by Aral Balkan's avatar Aral Balkan
Browse files

The private timeline is now persisting into LevelDB in Node.

parent b8d87184
......@@ -141,8 +141,28 @@ class MessageSplitViewController: NSSplitViewController
//
let message = Message(id: messageFileName, assetURLPrefix: assetURLPrefix, folderURL: fileURL, html: indexHTML as String, synced: false)
//
// Notify that we need to have the message displayed in the respective timeline
//
post(MessageNotification.named(.ShowMessage), from: self, with: ["message": message])
//
// Inform Node that it should post the message to the timeline
// (TODO: Research: should we base this on the Pulse event flow instead? Which is cleaner?)
//
// Note: In the arguments, below:
// * message file name is the message ID
// * message body is the indexHTML
// *
//
Node.sharedInstance.call(remoteFunction.named(.postMessage), withArguments: [messageFileName, indexHTML, CurrentTimeline.id!])
{
/* and handle callback with */ result in
println("<<<<< POST MESSAGE CALLBACK!!!! >>>>>")
println(result)
}
break
}
}
......
......@@ -16,6 +16,7 @@ public enum remoteFunction:String
case hasWaystoneAccount = "hasWaystoneAccount"
case isHandleAvailable = "isHandleAvailable"
case isInvitationCodeValid = "isInvitationCodeValid"
case postMessage = "postMessage"
case initialiseHeartbeatWithWaystoneAccount = "initialiseHeartbeatWithWaystoneAccount"
......@@ -110,7 +111,8 @@ public class Node: NSObject, WebSocketDelegate
//
public class var sharedInstance:Node
{
struct Static {
struct Static
{
static let instance:Node = Node()
}
return Static.instance
......@@ -128,7 +130,7 @@ public class Node: NSObject, WebSocketDelegate
// Launch node task.
//
println("Cocoa: Launching Node connection. Start all services at launch = \(startAllServicesAtLaunch)")
println("\(self) Cocoa: Launching Node connection. Start all services at launch = \(startAllServicesAtLaunch)")
let mainBundle = NSBundle.mainBundle()
......@@ -436,16 +438,29 @@ public class Node: NSObject, WebSocketDelegate
println("RPC Function call JSON: \(json)")
let jsonData:NSData = json.rawData()!
socket!.writeData(jsonData)
//
// Add some metadata and save the function details in the list of calls in progress
// so we know which callback to call and can time calls, etc.
//
functionDetails["timestamp"] = NSDate()
remoteFunctionCallRequests[remoteFunctionCallUniqueID] = functionDetails
if let jsonData:NSData = json.rawData()
{
if let socket = socket
{
socket.writeData(jsonData)
//
// Add some metadata and save the function details in the list of calls in progress
// so we know which callback to call and can time calls, etc.
//
functionDetails["timestamp"] = NSDate()
remoteFunctionCallRequests[remoteFunctionCallUniqueID] = functionDetails
}
else
{
fatalError("\(self) Socket does not exist.")
}
}
else
{
fatalError("\(self) Could not convert remote function arguments to JSON: \(arguments)")
}
}
......
......@@ -21,6 +21,7 @@ let TimelineNavigationRequestNotification:String = "TimelineNavigationRequestNot
public struct CurrentTimeline
{
static var id:String?
static var name:String?
static var path:String?
static var relativeWebPrefix:String?
......@@ -319,9 +320,11 @@ class TimelineViewController: NSViewController
self.currentTimeline = timeline
// Update the CurrentTimeline Model
// TODO: Instead of this ridiculous shallow copy, just store the timeline reference.
CurrentTimeline.name = timeline.title
CurrentTimeline.path = timeline.path
CurrentTimeline.relativeWebPrefix = timeline.relativeWebPrefix
CurrentTimeline.id = timeline.id
// Notify anyone who cares that the timeline has changed.
post(TimelineNotification.named(.TimelineDidChange), from: self)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment