mirror of
				https://github.com/matrix-org/gomatrix
				synced 2025-11-03 22:08:04 +00:00 
			
		
		
		
	Add working example
This commit is contained in:
		
							parent
							
								
									519d03ed04
								
							
						
					
					
						commit
						5391ef3078
					
				
					 1 changed files with 8 additions and 10 deletions
				
			
		
							
								
								
									
										18
									
								
								client.go
									
										
									
									
									
								
							
							
						
						
									
										18
									
								
								client.go
									
										
									
									
									
								
							| 
						 | 
					@ -3,16 +3,14 @@
 | 
				
			||||||
// Specification can be found at http://matrix.org/docs/spec/client_server/r0.2.0.html
 | 
					// Specification can be found at http://matrix.org/docs/spec/client_server/r0.2.0.html
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// Example usage of this library: (blocking version)
 | 
					// Example usage of this library: (blocking version)
 | 
				
			||||||
//   cli, err := gomatrix.NewClient("https://matrix.org", "@example:matrix.org", "abcdef123456")
 | 
					// 	cli, _ := gomatrix.NewClient("https://matrix.org", "@example:matrix.org", "MDAefhiuwehfuiwe")
 | 
				
			||||||
//   if err != nil {
 | 
					//	syncer := cli.Syncer.(*gomatrix.DefaultSyncer)
 | 
				
			||||||
//       panic(err)
 | 
					//	syncer.OnEventType("m.room.message", func(ev *gomatrix.Event) {
 | 
				
			||||||
//   }
 | 
					//		fmt.Println("Message: ", ev)
 | 
				
			||||||
//   cli.Syncer.OnEventType("m.room.message", func(ev *gomatrix.Event) {
 | 
					//	})
 | 
				
			||||||
//	     fmt.Println("Message: %+v", ev)
 | 
					//	if err := cli.Sync(); err != nil {
 | 
				
			||||||
//   })
 | 
					//		fmt.Println("Sync() returned ", err)
 | 
				
			||||||
//   if err := cli.Sync(); err != nil {
 | 
					//	}
 | 
				
			||||||
//       panic(err)
 | 
					 | 
				
			||||||
//   }
 | 
					 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// To make the example non-blocking, call Sync() in a goroutine.
 | 
					// To make the example non-blocking, call Sync() in a goroutine.
 | 
				
			||||||
package gomatrix
 | 
					package gomatrix
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue