, request_
, sendRequest
, sendNotification
- , sendRequestMessage
- , sendNotification'
, sendResponse
-- * Receving
, message
object ["jsonrpc" .= rpc, "id" .= id, "method" .= method, "params" .= params]
-sendRequestMessage :: (ToJSON a, ToJSON b) => RequestMessage ClientMethod a b -> Session ()
-sendRequestMessage req = do
- -- Update the request map
- reqMap <- requestMap <$> ask
- liftIO $ modifyMVar_ reqMap $
- \r -> return $ updateRequestMap r (req ^. LSP.id) (req ^. method)
-
- sendMessage req
-
-- | Sends a notification to the server.
sendNotification :: ToJSON a
=> ClientMethod -- ^ The notification method.
oldVFS <- vfs <$> get
newVFS <- liftIO $ openVFS oldVFS n
modify (\s -> s { vfs = newVFS })
- sendNotification' n
+ sendMessage n
-- | Close a virtual file if we send a close text document notification
sendNotification TextDocumentDidClose params = do
oldVFS <- vfs <$> get
newVFS <- liftIO $ closeVFS oldVFS n
modify (\s -> s { vfs = newVFS })
- sendNotification' n
-
-sendNotification method params = sendNotification' (NotificationMessage "2.0" method params)
+ sendMessage n
-sendNotification' :: (ToJSON a, ToJSON b) => NotificationMessage a b -> Session ()
-sendNotification' = sendMessage
+sendNotification method params = sendMessage (NotificationMessage "2.0" method params)
sendResponse :: ToJSON a => ResponseMessage a -> Session ()
sendResponse = sendMessage
notification msg@(NotificationMessage _ Exit _) = do
liftIO $ putStrLn "Will send exit notification soon"
liftIO $ threadDelay 10000000
- sendNotification' msg
+ sendMessage msg
liftIO $ error "Done"
notification msg@(NotificationMessage _ m _) = do
- sendNotification' msg
+ sendMessage msg
liftIO $ putStrLn $ "Sent a notification " ++ show m
sendMessages remainingMsgs reqSema rspSema
+sendRequestMessage :: (ToJSON a, ToJSON b) => RequestMessage ClientMethod a b -> Session ()
+sendRequestMessage req = do
+ -- Update the request map
+ reqMap <- requestMap <$> ask
+ liftIO $ modifyMVar_ reqMap $
+ \r -> return $ updateRequestMap r (req ^. LSP.id) (req ^. method)
+
+ sendMessage req
+
isNotification :: FromServerMessage -> Bool
isNotification (NotPublishDiagnostics _) = True