0
# Server Communication
1
2
Core RPC communication functions for DevTools server connectivity, health monitoring, and project configuration access.
3
4
## Capabilities
5
6
### Health Check
7
8
Simple heartbeat function to verify server connectivity and RPC communication.
9
10
```typescript { .api }
11
/**
12
* Simple heartbeat function for server connectivity verification
13
* @returns Always returns true to confirm server is responsive
14
*/
15
function heartbeat(): boolean;
16
```
17
18
**Usage Example:**
19
20
```typescript
21
// Verify server connection
22
const isAlive = heartbeat();
23
console.log('Server responsive:', isAlive); // Always true if connection works
24
```
25
26
### Project Configuration
27
28
Access to core project configuration information.
29
30
```typescript { .api }
31
/**
32
* Gets the project root directory path
33
* @returns Project root directory as absolute path
34
*/
35
function getRoot(): string;
36
```
37
38
**Usage Example:**
39
40
```typescript
41
const projectRoot = getRoot();
42
console.log('Project root:', projectRoot);
43
// Result: "/Users/developer/my-vue-project"
44
```
45
46
## RPC Infrastructure
47
48
These functions are part of the RPC (Remote Procedure Call) system that enables communication between the DevTools client and the Vite development server.
49
50
### Communication Flow
51
52
1. **Client Request**: DevTools client calls RPC function
53
2. **Server Processing**: Vite plugin processes the request
54
3. **Response**: Server returns result to client
55
4. **Real-time Updates**: Server can broadcast updates to all connected clients
56
57
### Error Handling
58
59
RPC functions handle common error scenarios:
60
61
- **Connection Issues**: Functions will throw if server is unreachable
62
- **Invalid Parameters**: Type validation ensures proper parameter handling
63
- **Server Errors**: Internal server errors are properly propagated to client
64
65
### Integration with Other Functions
66
67
Server communication functions work alongside other DevTools capabilities:
68
69
- **Asset Analysis**: Uses server filesystem access for asset scanning
70
- **Module Graph**: Leverages Vite's internal module tracking
71
- **Component Inspector**: Coordinates with development server for file editing